Setup¶

Install in R:

install.packages("BiocManager")
BiocManager::install(c("edgeR", "BiocParallel", "RhpcBLASctl"))

Install

pip install toytree ete4 pybiomart

Options & Data¶

In [ ]:
%load_ext autoreload
%autoreload 2

import os
import re
import pickle
import matplotlib.pyplot as plt
import warnings
import logging
import seaborn as sns
from scipy.sparse import issparse
from pymer4.models import lmer, lm, glmer, compare
from pymer4 import config
import polars
import statsmodels.api as sm
import senepy
import gseapy as gp
import pertpy as pt
import scanpy as sc
import pandas as pd
import numpy as np
import scflow
from scflow.ax import find_senescence_genes, run_senepy

# Display/Environment Settings
os.environ["KMP_DUPLICATE_LIB_OK"] = "True"
warnings.filterwarnings("ignore", message=".*ast.Ellipsis is deprecated.*")
config.PANDAS_BACKEND = True
warnings.filterwarnings("ignore", message=".*vert.*will be deprecated.*")
pd.set_option("display.max_rows", 500)  # or None for unlimited rows
pd.set_option("display.max_columns", 100)
pd.set_option("display.max_colwidth", 100)
pd.set_option("display.width", 300)
warnings.filterwarnings(
    "ignore", message="Bitwise inversion '~' on bool is deprecated",
    category=DeprecationWarning)

# Process Options
ncpus = os.cpu_count() - 1
overwrite = True

# If You Want Results Emailed (Will Overwrite HTML Regardless of `overwite`)
cur_file = os.path.join(os.path.abspath(""), "analyze_senescence_celltype"
                        "_specific_threshold.ipynb")
html_out = os.path.splitext(cur_file)[0] + ".html"
email = "elizabeth.aslinger@aya.yale.edu"
# set email to None to skip

# Cell Type Label Column
col_celltype = "annotation_scanvi"
# col_celltype = "annotation_by_overlap"
# col_celltype = "Annotation_ToppGene"
# col_celltype = "cellmap_class_name"
# col_celltype = "cellmap_class_name_collapsed"
# use_hierarchy = False
collapse_neurons = True  # collapse neuron categories?

# Metadata Information
species = "Mouse"
col_sample, col_batch = "sample", "Group"
# col_age = "Characteristics[Age at Euthanasia]"
# col_condition = "Factor Value[Spaceflight]"
col_age = "Age_End"
col_condition = "Condition"
# group_order = ["Ground Control | 12 Weeks", "Ground Control | 29 Weeks",
#                "Space Flight | 12 Weeks", "Space Flight | 29 Weeks"]
group_order = ["Ground Control | 20 Weeks", "Ground Control | 37 Weeks",
               "Space Flight | 20 Weeks", "Space Flight | 37 Weeks"]
keys = {col_condition: dict(key_control="Ground Control",
                            key_treatment="Space Flight"),
        col_age: dict(key_control="20 Weeks",
                      key_treatment="37 Weeks"),
        # col_age: dict(key_control="12 Weeks",
        #               key_treatment="29 Weeks"),
        col_batch: dict(key_control=group_order[0],
                        key_treatment=group_order[1:])}
palette = {col_condition: {keys[col_condition]["key_control"]: "b",
                           keys[col_condition]["key_treatment"]: "r"},
           col_age: {keys[col_age]["key_control"]: "g",
                     keys[col_age]["key_treatment"]: "y"},
           col_batch: dict(zip(group_order, ["c", "b", "tab:pink", "r"]))}

# Scoring Metrics
sen_metrics = ["senmayo"]
# sen_metrics = ["senepy", "senmayo"]
use_metric = "senmayo"
percentile = 1

# Regress Out Confounders?
vars_regress_out = ["Time"]

# File Input & Output
file_path = "data/OSD-613_integrated.h5ad"
file_path_new = os.path.splitext(file_path)[0] + "_analyzed.h5ad"

# Load Data
self = scflow.Rna(file_path, col_sample=col_sample, col_batch=col_batch,
                  col_celltype=col_celltype)  # data
self.rna.obs.loc[:, col_batch] = self.rna.obs[col_batch].astype(
    pd.CategoricalDtype(categories=group_order, ordered=True))
self.rna = self.rna[:, self.rna.var.mt == False]  # snRNA-seq so remove MT-
self.rna = self.rna[:, self.rna.var.ribo == False]  # snRNA-seq so remove RB-
self.rna.obs.loc[:, "Spaceflight"] = (self.rna.obs[col_condition] == keys[
    col_condition]["key_treatment"]).astype(int)  # 1 vs. 0 spaceflight
self.rna.obs.loc[:, "Aged"] = (self.rna.obs[col_age] == keys[
    col_age]["key_treatment"]).astype(int)  # 1 vs. 0 older
self.rna.X = self.rna.layers["log1p"].copy()
self.rna.raw = None

# Hierarchical
keys_cts = {"Neurons": ["Excitatory", "Inhibitory",
                        "Excitatory-Inhibitory", "Neuron"],
            "Macroglia": ["Oligodendrocyte", "OPC", "Astrocyte"],
            "Microglia": ["Microglial"],
            "Endothelial Cell": ["Endothelial"]}
key_cts = dict(pd.concat([pd.Series(dict(([(i, x) for i in keys_cts[
    x]]))) for x in keys_cts]))
if collapse_neurons is True:
    self.rna.obs.loc[:, f"{col_celltype}_collapsed"] = self.rna.obs[
        col_celltype].replace(dict(zip(keys_cts["Neurons"], ["Neurons"]*3)))
    col_celltype = f"{col_celltype}_collapsed"
    self.col_celltype = col_celltype
self.rna.obs.loc[:, f"{col_celltype}_hierarchy"] = self.rna.obs[
    col_celltype].replace(key_cts)

# Display Object
print(self.rna)
print(self.rna.obs.groupby(col_sample).describe())
self.rna.obs
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/senepy/load_hubs.py:3: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  from pkg_resources import resource_filename
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/marshmallow/__init__.py:17: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  __version_info__ = tuple(LooseVersion(__version__).version)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/marshmallow/fields.py:198: RemovedInMarshmallow4Warning: Passing field metadata as a keyword arg is deprecated. Use the explicit `metadata=...` argument instead.
  warnings.warn(
AnnData object with n_obs × n_vars = 103274 × 12097
    obs: 'Group', 'sample', 'Sample Number', 'Characteristics[Organism]', 'Term Source REF', 'Term Accession Number', 'Characteristics[Strain]', 'Term Source REF.1', 'Term Accession Number.1', 'Characteristics[Genotype]', 'Term Source REF.2', 'Term Accession Number.2', 'Characteristics[Animal Source]', 'Characteristics[Sex]', 'Term Source REF.3', 'Term Accession Number.3', 'Factor Value[Spaceflight]', 'Term Source REF.4', 'Term Accession Number.4', 'Factor Value[Age]', 'Unit', 'Term Source REF.5', 'Term Accession Number.5', 'Characteristics[Material Type]', 'Term Source REF.6', 'Term Accession Number.6', 'Characteristics[diet]', 'Characteristics[Feeding Schedule]', 'Characteristics[Age at Euthanasia]', 'Unit.1', 'Term Source REF.7', 'Term Accession Number.7', 'Protocol REF', 'Parameter Value[habitat]', 'Parameter Value[Enrichment material]', 'Parameter Value[duration]', 'Unit.2', 'Term Source REF.8', 'Term Accession Number.8', 'Parameter Value[light cycle]', 'Protocol REF.1', 'Parameter Value[Euthanasia Method]', 'Parameter Value[Sample Preservation Method]', 'Term Source REF.9', 'Term Accession Number.9', 'Parameter Value[Sample Storage Temperature]', 'Unit.3', 'Term Source REF.10', 'Term Accession Number.10', 'Comment[RFID]', 'Comment[Euthanasia Date]', 'Time', 'n_cells_original_sample', 'kws_pp_sample', 'n_genes_by_counts', 'total_counts', 'log1p_n_genes_by_counts', 'log1p_total_counts', 'total_counts_mt', 'pct_counts_mt', 'log1p_total_counts_mt', 'total_counts_ribo', 'pct_counts_ribo', 'log1p_total_counts_ribo', 'total_counts_hb', 'pct_counts_hb', 'log1p_total_counts_hb', 'n_counts', 'n_genes', 'doublet_score', 'predicted_doublet', 'leiden_individual_res0.2dist1.5', 'annotation_by_markers_individual_res0.2dist1.5', 'annotation_by_markers_individual_heterogeneous_collapsed', 'leiden_individual', 'annotation_by_markers_individual', 'kws_cluster_individual', 'annotation_scanvi', 'kws_integrate', 'leiden', 'leiden_resolution', 'leiden_n_neighbors', 'leiden_min_dist', 'leiden_subcluster', 'resolution_leiden_subcluster', 'annotation_by_overlap', 'majority_voting_short', 'Age_Start', 'Age_End', 'Condition', 'annotation_toppgene', 'predicted_labels', 'majority_voting', 'majority_voting_probabilities', 'annotation_majority_voting', 'Spaceflight', 'Aged', 'annotation_scanvi_collapsed', 'annotation_scanvi_collapsed_hierarchy'
    var: 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'mean', 'std', 'mt', 'ribo', 'hb', 'n_cells_by_counts', 'total_counts', 'mean_counts', 'pct_dropout_by_counts', 'log1p_total_counts', 'log1p_mean_counts'
    uns: 'Group_colors', 'annotation_majority_voting_colors', 'annotation_scanvi_colors', 'hvg', 'leiden', 'leiden_colors', 'leiden_subcluster', 'leiden_subcluster_colors', 'log1p', 'neighbors', 'over_clustering', 'rank_genes_groups_leiden', 'rank_genes_groups_leiden_subcluster', 'sample_colors', 'umap'
    obsm: 'X_pca', 'X_pca_old', 'X_scANVI', 'X_umap'
    layers: 'counts', 'log1p', 'scaled'
    obsp: 'connectivities', 'distances'
                             Factor Value[Age]                                          Characteristics[Age at Euthanasia]                                          Parameter Value[duration]                                          Parameter Value[Sample Storage Temperature]                         \
                                         count  mean  std   min   25%   50%   75%   max                              count  mean  std   min   25%   50%   75%   max                     count  mean  std   min   25%   50%   75%   max                                       count  mean  std   min   25%   
sample                                                                                                                                                                                                                                                                                                      
RRRM2_BRN_GC_ISS-T_YNG_GY4              7547.0  12.0  0.0  12.0  12.0  12.0  12.0  12.0                             7547.0  20.0  0.0  20.0  20.0  20.0  20.0  20.0                    7547.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      7547.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_GC_ISS-T_YNG_GY9              5465.0  12.0  0.0  12.0  12.0  12.0  12.0  12.0                             5465.0  20.0  0.0  20.0  20.0  20.0  20.0  20.0                    5465.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      5465.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_GC_ISS-T_OLD_GO18             5842.0  29.0  0.0  29.0  29.0  29.0  29.0  29.0                             5842.0  37.0  0.0  37.0  37.0  37.0  37.0  37.0                    5842.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      5842.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO20            4922.0  29.0  0.0  29.0  29.0  29.0  29.0  29.0                             4922.0  37.0  0.0  37.0  37.0  37.0  37.0  37.0                    4922.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      4922.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_GC_ISS-T_OLD_GO19             7539.0  29.0  0.0  29.0  29.0  29.0  29.0  29.0                             7539.0  37.0  0.0  37.0  37.0  37.0  37.0  37.0                    7539.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      7539.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_GC_ISS-T_OLD_GO13             3595.0  29.0  0.0  29.0  29.0  29.0  29.0  29.0                             3595.0  37.0  0.0  37.0  37.0  37.0  37.0  37.0                    3595.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      3595.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_FLT_ISS-T_YNG_FY8             5095.0  12.0  0.0  12.0  12.0  12.0  12.0  12.0                             5095.0  20.0  0.0  20.0  20.0  20.0  20.0  20.0                    5095.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      5095.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_FLT_ISS-T_YNG_FY7             3669.0  12.0  0.0  12.0  12.0  12.0  12.0  12.0                             3669.0  20.0  0.0  20.0  20.0  20.0  20.0  20.0                    3669.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      3669.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO19            5747.0  29.0  0.0  29.0  29.0  29.0  29.0  29.0                             5747.0  37.0  0.0  37.0  37.0  37.0  37.0  37.0                    5747.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      5747.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_GC_ISS-T_YNG_GY7              5265.0  12.0  0.0  12.0  12.0  12.0  12.0  12.0                             5265.0  20.0  0.0  20.0  20.0  20.0  20.0  20.0                    5265.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      5265.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO14            3864.0  29.0  0.0  29.0  29.0  29.0  29.0  29.0                             3864.0  37.0  0.0  37.0  37.0  37.0  37.0  37.0                    3864.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      3864.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_GC_ISS-T_YNG_GY1              3672.0  12.0  0.0  12.0  12.0  12.0  12.0  12.0                             3672.0  20.0  0.0  20.0  20.0  20.0  20.0  20.0                    3672.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      3672.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_FLT_ISS-T_YNG_FY2             3730.0  12.0  0.0  12.0  12.0  12.0  12.0  12.0                             3730.0  20.0  0.0  20.0  20.0  20.0  20.0  20.0                    3730.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      3730.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO17            1321.0  29.0  0.0  29.0  29.0  29.0  29.0  29.0                             1321.0  37.0  0.0  37.0  37.0  37.0  37.0  37.0                    1321.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      1321.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_GC_ISS-T_OLD_GO16            18386.0  29.0  0.0  29.0  29.0  29.0  29.0  29.0                            18386.0  37.0  0.0  37.0  37.0  37.0  37.0  37.0                   18386.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                     18386.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO16            4050.0  29.0  0.0  29.0  29.0  29.0  29.0  29.0                             4050.0  37.0  0.0  37.0  37.0  37.0  37.0  37.0                    4050.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      4050.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_GC_ISS-T_YNG_GY2              9651.0  12.0  0.0  12.0  12.0  12.0  12.0  12.0                             9651.0  20.0  0.0  20.0  20.0  20.0  20.0  20.0                    9651.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      9651.0 -80.0  0.0 -80.0 -80.0   
RRRM2_BRN_FLT_ISS-T_YNG_FY5             3914.0  12.0  0.0  12.0  12.0  12.0  12.0  12.0                             3914.0  20.0  0.0  20.0  20.0  20.0  20.0  20.0                    3914.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0                                      3914.0 -80.0  0.0 -80.0 -80.0   

                                                   Time                                                      n_cells_original_sample                                                            n_genes_by_counts               ... leiden_resolution         leiden_n_neighbors                         \
                               50%   75%   max    count    mean  std     min     25%     50%     75%     max                   count     mean  std      min      25%      50%      75%      max             count         mean  ...               75%     max              count  mean  std   min   25%   
sample                                                                                                                                                                                                                          ...                                                                       
RRRM2_BRN_GC_ISS-T_YNG_GY4   -80.0 -80.0 -80.0   7547.0  1149.0  0.0  1149.0  1149.0  1149.0  1149.0  1149.0                  7547.0   8542.0  0.0   8542.0   8542.0   8542.0   8542.0   8542.0            7547.0  1464.316152  ...            0.0075  0.0075             7547.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_GC_ISS-T_YNG_GY9   -80.0 -80.0 -80.0   5465.0   961.0  0.0   961.0   961.0   961.0   961.0   961.0                  5465.0   6044.0  0.0   6044.0   6044.0   6044.0   6044.0   6044.0            5465.0  2703.472827  ...            0.0075  0.0075             5465.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_GC_ISS-T_OLD_GO18  -80.0 -80.0 -80.0   5842.0  1064.0  0.0  1064.0  1064.0  1064.0  1064.0  1064.0                  5842.0   6503.0  0.0   6503.0   6503.0   6503.0   6503.0   6503.0            5842.0  1678.743923  ...            0.0075  0.0075             5842.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO20 -80.0 -80.0 -80.0   4922.0   915.0  0.0   915.0   915.0   915.0   915.0   915.0                  4922.0   5641.0  0.0   5641.0   5641.0   5641.0   5641.0   5641.0            4922.0  2467.499187  ...            0.0075  0.0075             4922.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_GC_ISS-T_OLD_GO19  -80.0 -80.0 -80.0   7539.0  1085.0  0.0  1085.0  1085.0  1085.0  1085.0  1085.0                  7539.0   8476.0  0.0   8476.0   8476.0   8476.0   8476.0   8476.0            7539.0  2632.348985  ...            0.0075  0.0075             7539.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_GC_ISS-T_OLD_GO13  -80.0 -80.0 -80.0   3595.0  1139.0  0.0  1139.0  1139.0  1139.0  1139.0  1139.0                  3595.0   3880.0  0.0   3880.0   3880.0   3880.0   3880.0   3880.0            3595.0  2588.294298  ...            0.0075  0.0075             3595.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_FLT_ISS-T_YNG_FY8  -80.0 -80.0 -80.0   5095.0   707.0  0.0   707.0   707.0   707.0   707.0   707.0                  5095.0   5658.0  0.0   5658.0   5658.0   5658.0   5658.0   5658.0            5095.0  2789.168008  ...            0.0075  0.0075             5095.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_FLT_ISS-T_YNG_FY7  -80.0 -80.0 -80.0   3669.0   661.0  0.0   661.0   661.0   661.0   661.0   661.0                  3669.0   4238.0  0.0   4238.0   4238.0   4238.0   4238.0   4238.0            3669.0  1567.765604  ...            0.0075  0.0075             3669.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO19 -80.0 -80.0 -80.0   5747.0   869.0  0.0   869.0   869.0   869.0   869.0   869.0                  5747.0   7265.0  0.0   7265.0   7265.0   7265.0   7265.0   7265.0            5747.0  1814.084218  ...            0.0075  0.0075             5747.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_GC_ISS-T_YNG_GY7   -80.0 -80.0 -80.0   5265.0  1210.0  0.0  1210.0  1210.0  1210.0  1210.0  1210.0                  5265.0   5776.0  0.0   5776.0   5776.0   5776.0   5776.0   5776.0            5265.0  2760.520608  ...            0.0075  0.0075             5265.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO14 -80.0 -80.0 -80.0   3864.0   870.0  0.0   870.0   870.0   870.0   870.0   870.0                  3864.0   4260.0  0.0   4260.0   4260.0   4260.0   4260.0   4260.0            3864.0  2855.340321  ...            0.0075  0.0075             3864.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_GC_ISS-T_YNG_GY1   -80.0 -80.0 -80.0   3672.0  1082.0  0.0  1082.0  1082.0  1082.0  1082.0  1082.0                  3672.0   3968.0  0.0   3968.0   3968.0   3968.0   3968.0   3968.0            3672.0  3256.512255  ...            0.0075  0.0075             3672.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_FLT_ISS-T_YNG_FY2  -80.0 -80.0 -80.0   3730.0   660.0  0.0   660.0   660.0   660.0   660.0   660.0                  3730.0   4125.0  0.0   4125.0   4125.0   4125.0   4125.0   4125.0            3730.0  3048.478284  ...            0.0075  0.0075             3730.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO17 -80.0 -80.0 -80.0   1321.0   704.0  0.0   704.0   704.0   704.0   704.0   704.0                  1321.0   1493.0  0.0   1493.0   1493.0   1493.0   1493.0   1493.0            1321.0  1323.376230  ...            0.0075  0.0075             1321.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_GC_ISS-T_OLD_GO16  -80.0 -80.0 -80.0  18386.0  1019.0  0.0  1019.0  1019.0  1019.0  1019.0  1019.0                 18386.0  20000.0  0.0  20000.0  20000.0  20000.0  20000.0  20000.0           18386.0   996.987110  ...            0.0075  0.0075            18386.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO16 -80.0 -80.0 -80.0   4050.0   650.0  0.0   650.0   650.0   650.0   650.0   650.0                  4050.0   4863.0  0.0   4863.0   4863.0   4863.0   4863.0   4863.0            4050.0  3231.898025  ...            0.0075  0.0075             4050.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_GC_ISS-T_YNG_GY2   -80.0 -80.0 -80.0   9651.0  1107.0  0.0  1107.0  1107.0  1107.0  1107.0  1107.0                  9651.0  10779.0  0.0  10779.0  10779.0  10779.0  10779.0  10779.0            9651.0  2324.572998  ...            0.0075  0.0075             9651.0  15.0  0.0  15.0  15.0   
RRRM2_BRN_FLT_ISS-T_YNG_FY5  -80.0 -80.0 -80.0   3914.0   885.0  0.0   885.0   885.0   885.0   885.0   885.0                  3914.0   4714.0  0.0   4714.0   4714.0   4714.0   4714.0   4714.0            3914.0  3249.220235  ...            0.0075  0.0075             3914.0  15.0  0.0  15.0  15.0   

                                               leiden_min_dist                                             resolution_leiden_subcluster                                                         majority_voting_probabilities                                                                       \
                               50%   75%   max           count mean           std  min  25%  50%  75%  max                        count   mean           std    min    25%    50%    75%    max                         count      mean       std           min       25%       50%       75%  max   
sample                                                                                                                                                                                                                                                                                               
RRRM2_BRN_GC_ISS-T_YNG_GY4    15.0  15.0  15.0          7547.0  1.8  4.441186e-16  1.8  1.8  1.8  1.8  1.8                       7547.0  0.005  8.674192e-19  0.005  0.005  0.005  0.005  0.005                        5985.0  0.728018  0.354468  3.282433e-08  0.500470  0.935991  0.994391  1.0   
RRRM2_BRN_GC_ISS-T_YNG_GY9    15.0  15.0  15.0          5465.0  1.8  6.661948e-16  1.8  1.8  1.8  1.8  1.8                       5465.0  0.005  8.674411e-19  0.005  0.005  0.005  0.005  0.005                        5020.0  0.812074  0.320982  1.326950e-08  0.820617  0.984462  0.998907  1.0   
RRRM2_BRN_GC_ISS-T_OLD_GO18   15.0  15.0  15.0          5842.0  1.8  0.000000e+00  1.8  1.8  1.8  1.8  1.8                       5842.0  0.005  8.674360e-19  0.005  0.005  0.005  0.005  0.005                        5406.0  0.764825  0.332948  4.650237e-10  0.621054  0.956966  0.995094  1.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO20  15.0  15.0  15.0          4922.0  1.8  4.441343e-16  1.8  1.8  1.8  1.8  1.8                       4922.0  0.005  0.000000e+00  0.005  0.005  0.005  0.005  0.005                        4787.0  0.808646  0.316059  3.679113e-12  0.772958  0.982582  0.998239  1.0   
RRRM2_BRN_GC_ISS-T_OLD_GO19   15.0  15.0  15.0          7539.0  1.8  4.441187e-16  1.8  1.8  1.8  1.8  1.8                       7539.0  0.005  8.674193e-19  0.005  0.005  0.005  0.005  0.005                        7081.0  0.823671  0.311928  9.216436e-11  0.848215  0.986549  0.998814  1.0   
RRRM2_BRN_GC_ISS-T_OLD_GO13   15.0  15.0  15.0          3595.0  1.8  4.441510e-16  1.8  1.8  1.8  1.8  1.8                       3595.0  0.005  0.000000e+00  0.005  0.005  0.005  0.005  0.005                        3306.0  0.848197  0.302598  4.892193e-13  0.911656  0.996120  0.999868  1.0   
RRRM2_BRN_FLT_ISS-T_YNG_FY8   15.0  15.0  15.0          5095.0  1.8  2.220664e-16  1.8  1.8  1.8  1.8  1.8                       5095.0  0.005  8.674469e-19  0.005  0.005  0.005  0.005  0.005                        4562.0  0.798287  0.335168  2.489281e-06  0.771845  0.987226  0.999250  1.0   
RRRM2_BRN_FLT_ISS-T_YNG_FY7   15.0  15.0  15.0          3669.0  1.8  4.441497e-16  1.8  1.8  1.8  1.8  1.8                       3669.0  0.005  0.000000e+00  0.005  0.005  0.005  0.005  0.005                        3377.0  0.718330  0.355182  2.563253e-05  0.474151  0.925275  0.993546  1.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO19  15.0  15.0  15.0          5747.0  1.8  4.441279e-16  1.8  1.8  1.8  1.8  1.8                       5747.0  0.005  0.000000e+00  0.005  0.005  0.005  0.005  0.005                        3944.0  0.815628  0.314699  7.947201e-11  0.819162  0.982113  0.998139  1.0   
RRRM2_BRN_GC_ISS-T_YNG_GY7    15.0  15.0  15.0          5265.0  1.8  0.000000e+00  1.8  1.8  1.8  1.8  1.8                       5265.0  0.005  8.674441e-19  0.005  0.005  0.005  0.005  0.005                        4800.0  0.845268  0.298211  1.508838e-09  0.898036  0.992874  0.999547  1.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO14  15.0  15.0  15.0          3864.0  1.8  6.662200e-16  1.8  1.8  1.8  1.8  1.8                       3864.0  0.005  0.000000e+00  0.005  0.005  0.005  0.005  0.005                        3611.0  0.842997  0.299145  4.102560e-09  0.892723  0.991445  0.999444  1.0   
RRRM2_BRN_GC_ISS-T_YNG_GY1    15.0  15.0  15.0          3672.0  1.8  4.441497e-16  1.8  1.8  1.8  1.8  1.8                       3672.0  0.005  0.000000e+00  0.005  0.005  0.005  0.005  0.005                        3293.0  0.835006  0.300631  9.044592e-08  0.863981  0.990512  0.999500  1.0   
RRRM2_BRN_FLT_ISS-T_YNG_FY2   15.0  15.0  15.0          3730.0  1.8  4.441488e-16  1.8  1.8  1.8  1.8  1.8                       3730.0  0.005  8.674780e-19  0.005  0.005  0.005  0.005  0.005                        3458.0  0.820929  0.321241  9.661173e-08  0.844128  0.989742  0.999332  1.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO17  15.0  15.0  15.0          1321.0  1.8  0.000000e+00  1.8  1.8  1.8  1.8  1.8                       1321.0  0.005  8.676902e-19  0.005  0.005  0.005  0.005  0.005                         615.0  0.771479  0.333113  1.526836e-05  0.681785  0.965615  0.996596  1.0   
RRRM2_BRN_GC_ISS-T_OLD_GO16   15.0  15.0  15.0         18386.0  1.8  4.441013e-16  1.8  1.8  1.8  1.8  1.8                      18386.0  0.005  0.000000e+00  0.005  0.005  0.005  0.005  0.005                        5992.0  0.722214  0.355449  2.281540e-10  0.464056  0.934043  0.993215  1.0   
RRRM2_BRN_FLT_ISS-T_OLD_FO16  15.0  15.0  15.0          4050.0  1.8  4.441440e-16  1.8  1.8  1.8  1.8  1.8                       4050.0  0.005  0.000000e+00  0.005  0.005  0.005  0.005  0.005                        3742.0  0.828101  0.312903  6.212262e-06  0.863965  0.988976  0.999134  1.0   
RRRM2_BRN_GC_ISS-T_YNG_GY2    15.0  15.0  15.0          9651.0  1.8  2.220561e-16  1.8  1.8  1.8  1.8  1.8                       9651.0  0.005  0.000000e+00  0.005  0.005  0.005  0.005  0.005                        9040.0  0.811864  0.311791  2.103236e-10  0.792671  0.980873  0.998145  1.0   
RRRM2_BRN_FLT_ISS-T_YNG_FY5   15.0  15.0  15.0          3914.0  1.8  4.441460e-16  1.8  1.8  1.8  1.8  1.8                       3914.0  0.005  0.000000e+00  0.005  0.005  0.005  0.005  0.005                        3721.0  0.843357  0.293269  1.672285e-07  0.876753  0.989395  0.998910  1.0   

                             Spaceflight                                        Aged                                     
                                   count mean  std  min  25%  50%  75%  max    count mean  std  min  25%  50%  75%  max  
sample                                                                                                                   
RRRM2_BRN_GC_ISS-T_YNG_GY4        7547.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0   7547.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  
RRRM2_BRN_GC_ISS-T_YNG_GY9        5465.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0   5465.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  
RRRM2_BRN_GC_ISS-T_OLD_GO18       5842.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0   5842.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0  
RRRM2_BRN_FLT_ISS-T_OLD_FO20      4922.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0   4922.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0  
RRRM2_BRN_GC_ISS-T_OLD_GO19       7539.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0   7539.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0  
RRRM2_BRN_GC_ISS-T_OLD_GO13       3595.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0   3595.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0  
RRRM2_BRN_FLT_ISS-T_YNG_FY8       5095.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0   5095.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  
RRRM2_BRN_FLT_ISS-T_YNG_FY7       3669.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0   3669.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  
RRRM2_BRN_FLT_ISS-T_OLD_FO19      5747.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0   5747.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0  
RRRM2_BRN_GC_ISS-T_YNG_GY7        5265.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0   5265.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  
RRRM2_BRN_FLT_ISS-T_OLD_FO14      3864.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0   3864.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0  
RRRM2_BRN_GC_ISS-T_YNG_GY1        3672.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0   3672.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  
RRRM2_BRN_FLT_ISS-T_YNG_FY2       3730.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0   3730.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  
RRRM2_BRN_FLT_ISS-T_OLD_FO17      1321.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0   1321.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0  
RRRM2_BRN_GC_ISS-T_OLD_GO16      18386.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  18386.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0  
RRRM2_BRN_FLT_ISS-T_OLD_FO16      4050.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0   4050.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0  
RRRM2_BRN_GC_ISS-T_YNG_GY2        9651.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0   9651.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  
RRRM2_BRN_FLT_ISS-T_YNG_FY5       3914.0  1.0  0.0  1.0  1.0  1.0  1.0  1.0   3914.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  

[18 rows x 232 columns]
Out[ ]:
Group sample Sample Number Characteristics[Organism] Term Source REF Term Accession Number Characteristics[Strain] Term Source REF.1 Term Accession Number.1 Characteristics[Genotype] Term Source REF.2 Term Accession Number.2 Characteristics[Animal Source] Characteristics[Sex] Term Source REF.3 Term Accession Number.3 Factor Value[Spaceflight] Term Source REF.4 Term Accession Number.4 Factor Value[Age] Unit Term Source REF.5 Term Accession Number.5 Characteristics[Material Type] Term Source REF.6 Term Accession Number.6 Characteristics[diet] Characteristics[Feeding Schedule] Characteristics[Age at Euthanasia] Unit.1 Term Source REF.7 Term Accession Number.7 Protocol REF Parameter Value[habitat] Parameter Value[Enrichment material] Parameter Value[duration] Unit.2 Term Source REF.8 Term Accession Number.8 Parameter Value[light cycle] Protocol REF.1 Parameter Value[Euthanasia Method] Parameter Value[Sample Preservation Method] Term Source REF.9 Term Accession Number.9 Parameter Value[Sample Storage Temperature] Unit.3 Term Source REF.10 Term Accession Number.10 Comment[RFID] Comment[Euthanasia Date] Time n_cells_original_sample kws_pp_sample n_genes_by_counts total_counts log1p_n_genes_by_counts log1p_total_counts total_counts_mt pct_counts_mt log1p_total_counts_mt total_counts_ribo pct_counts_ribo log1p_total_counts_ribo total_counts_hb pct_counts_hb log1p_total_counts_hb n_counts n_genes doublet_score predicted_doublet leiden_individual_res0.2dist1.5 annotation_by_markers_individual_res0.2dist1.5 annotation_by_markers_individual_heterogeneous_collapsed leiden_individual annotation_by_markers_individual kws_cluster_individual annotation_scanvi kws_integrate leiden leiden_resolution leiden_n_neighbors leiden_min_dist leiden_subcluster resolution_leiden_subcluster annotation_by_overlap majority_voting_short Age_Start Age_End Condition annotation_toppgene predicted_labels majority_voting majority_voting_probabilities annotation_majority_voting Spaceflight Aged annotation_scanvi_collapsed annotation_scanvi_collapsed_hierarchy
AAACAGCCAATCGCAC-1_RRRM2_BRN_GC_ISS-T_YNG_GY4 Ground Control | 20 Weeks RRRM2_BRN_GC_ISS-T_YNG_GY4 HGC-ISS-04 Mus musculus NCBITAXON http://purl.bioontology.org/ontology/NCBITAXON/10090 C57BL/6NTac EFO http://www.ebi.ac.uk/efo/EFO_0020093 Wild Type NCIT http://purl.obolibrary.org/obo/NCIT_C62195 Taconic Biosciences Female MESH http://purl.bioontology.org/ontology/MESH/D005260 Ground Control OSD https://osdr.nasa.gov/ 12 week UO http://purl.obolibrary.org/obo/UO_0000034 Left cerebral hemisphere FMA http://purl.org/sig/ont/fma/fma61819 Nutrient Upgraded Rodent Food Bar (NuRFB) ad libitum 20 week UO http://purl.obolibrary.org/obo/UO_0000034 Animal Husbandry Rodent Flight Hardware (Transporter and Habitat) Hut 53 day UO http://purl.obolibrary.org/obo/UO_0000033 12 h light/dark cycle sample collection Bilateral thoracotomy with sedation, Cardiac puncture with sedation, Ketamine/xylazine injection Liquid Nitrogen NCIT http://purl.obolibrary.org/obo/NCIT_C68796 -80 degree Celsius UO http://purl.obolibrary.org/obo/UO_0000027 6E2A671967 18-Sep-2019 1149.0 8542 {'min_max_genes': [321.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [4... 2074 2981.067871 7.637716 8.000372 13.387463 0.449083 2.666357 10.547901 0.353830 2.446504 1.628919 0.054642 0.966573 4962.0 2152 0.030852 False 1 Neuron Neuron 1 Neuron {'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50} Neuron {'col_celltype': 'annotation_by_markers_individual_heterogeneous_collapsed', 'flavor': 'scanvi',... 0 0.0075 15 1.8 0,0 0.005 Neuron L4/5 IT CTX Glut 12 Weeks 20 Weeks Ground Control Excitatory 006 L4/5 IT CTX Glut 006 L4/5 IT CTX Glut 0.842869 Glutamatergic 0 0 Neuron Neurons
AAACAGCCAGCACCAT-1_RRRM2_BRN_GC_ISS-T_YNG_GY4 Ground Control | 20 Weeks RRRM2_BRN_GC_ISS-T_YNG_GY4 HGC-ISS-04 Mus musculus NCBITAXON http://purl.bioontology.org/ontology/NCBITAXON/10090 C57BL/6NTac EFO http://www.ebi.ac.uk/efo/EFO_0020093 Wild Type NCIT http://purl.obolibrary.org/obo/NCIT_C62195 Taconic Biosciences Female MESH http://purl.bioontology.org/ontology/MESH/D005260 Ground Control OSD https://osdr.nasa.gov/ 12 week UO http://purl.obolibrary.org/obo/UO_0000034 Left cerebral hemisphere FMA http://purl.org/sig/ont/fma/fma61819 Nutrient Upgraded Rodent Food Bar (NuRFB) ad libitum 20 week UO http://purl.obolibrary.org/obo/UO_0000034 Animal Husbandry Rodent Flight Hardware (Transporter and Habitat) Hut 53 day UO http://purl.obolibrary.org/obo/UO_0000033 12 h light/dark cycle sample collection Bilateral thoracotomy with sedation, Cardiac puncture with sedation, Ketamine/xylazine injection Liquid Nitrogen NCIT http://purl.obolibrary.org/obo/NCIT_C68796 -80 degree Celsius UO http://purl.obolibrary.org/obo/UO_0000027 6E2A671967 18-Sep-2019 1149.0 8542 {'min_max_genes': [321.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [4... 1568 2737.962158 7.358194 7.915334 13.935327 0.508967 2.703729 13.991938 0.511035 2.707513 1.490915 0.054453 0.912650 2994.0 1636 0.052691 False 13 Neuron Neuron 13 Neuron {'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50} Neuron {'col_celltype': 'annotation_by_markers_individual_heterogeneous_collapsed', 'flavor': 'scanvi',... 0 0.0075 15 1.8 0,0 0.005 Neuron PVT-PT Ntrk1 Glut 12 Weeks 20 Weeks Ground Control Excitatory 149 PVT-PT Ntrk1 Glut 149 PVT-PT Ntrk1 Glut 0.813551 Glutamatergic 0 0 Neuron Neurons
AAACAGCCAGGTTCAC-1_RRRM2_BRN_GC_ISS-T_YNG_GY4 Ground Control | 20 Weeks RRRM2_BRN_GC_ISS-T_YNG_GY4 HGC-ISS-04 Mus musculus NCBITAXON http://purl.bioontology.org/ontology/NCBITAXON/10090 C57BL/6NTac EFO http://www.ebi.ac.uk/efo/EFO_0020093 Wild Type NCIT http://purl.obolibrary.org/obo/NCIT_C62195 Taconic Biosciences Female MESH http://purl.bioontology.org/ontology/MESH/D005260 Ground Control OSD https://osdr.nasa.gov/ 12 week UO http://purl.obolibrary.org/obo/UO_0000034 Left cerebral hemisphere FMA http://purl.org/sig/ont/fma/fma61819 Nutrient Upgraded Rodent Food Bar (NuRFB) ad libitum 20 week UO http://purl.obolibrary.org/obo/UO_0000034 Animal Husbandry Rodent Flight Hardware (Transporter and Habitat) Hut 53 day UO http://purl.obolibrary.org/obo/UO_0000033 12 h light/dark cycle sample collection Bilateral thoracotomy with sedation, Cardiac puncture with sedation, Ketamine/xylazine injection Liquid Nitrogen NCIT http://purl.obolibrary.org/obo/NCIT_C68796 -80 degree Celsius UO http://purl.obolibrary.org/obo/UO_0000027 6E2A671967 18-Sep-2019 1149.0 8542 {'min_max_genes': [321.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [4... 2953 3375.157715 7.990915 8.124494 1.556682 0.046122 0.938710 8.833843 0.261731 2.285830 0.000000 0.000000 0.000000 8625.0 3080 0.014899 False 6 Neuron Neuron 6 Neuron {'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50} Neuron {'col_celltype': 'annotation_by_markers_individual_heterogeneous_collapsed', 'flavor': 'scanvi',... 0 0.0075 15 1.8 0,1 0.005 Neuron L6b CTX Glut 12 Weeks 20 Weeks Ground Control Excitatory 029 L6b CTX Glut 029 L6b CTX Glut 0.337684 Glutamatergic 0 0 Neuron Neurons
AAACAGCCATCAATCG-1_RRRM2_BRN_GC_ISS-T_YNG_GY4 Ground Control | 20 Weeks RRRM2_BRN_GC_ISS-T_YNG_GY4 HGC-ISS-04 Mus musculus NCBITAXON http://purl.bioontology.org/ontology/NCBITAXON/10090 C57BL/6NTac EFO http://www.ebi.ac.uk/efo/EFO_0020093 Wild Type NCIT http://purl.obolibrary.org/obo/NCIT_C62195 Taconic Biosciences Female MESH http://purl.bioontology.org/ontology/MESH/D005260 Ground Control OSD https://osdr.nasa.gov/ 12 week UO http://purl.obolibrary.org/obo/UO_0000034 Left cerebral hemisphere FMA http://purl.org/sig/ont/fma/fma61819 Nutrient Upgraded Rodent Food Bar (NuRFB) ad libitum 20 week UO http://purl.obolibrary.org/obo/UO_0000034 Animal Husbandry Rodent Flight Hardware (Transporter and Habitat) Hut 53 day UO http://purl.obolibrary.org/obo/UO_0000033 12 h light/dark cycle sample collection Bilateral thoracotomy with sedation, Cardiac puncture with sedation, Ketamine/xylazine injection Liquid Nitrogen NCIT http://purl.obolibrary.org/obo/NCIT_C68796 -80 degree Celsius UO http://purl.obolibrary.org/obo/UO_0000027 6E2A671967 18-Sep-2019 1149.0 8542 {'min_max_genes': [321.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [4... 1071 2224.446777 6.977281 7.707713 5.198409 0.233694 1.824293 9.021851 0.405577 2.304768 0.000000 0.000000 0.000000 2017.0 1116 0.018405 False 10 Oligodendrocyte Oligodendrocyte 10 Oligodendrocyte {'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50} Oligodendrocyte {'col_celltype': 'annotation_by_markers_individual_heterogeneous_collapsed', 'flavor': 'scanvi',... 3 0.0075 15 1.8 3 0.005 Oligodendrocyte Oligo NN 12 Weeks 20 Weeks Ground Control Oligodendrocyte 327 Oligo NN 327 Oligo NN 0.999630 Oligodendrocyte 0 0 Oligodendrocyte Macroglia
AAACAGCCATGTCAAT-1_RRRM2_BRN_GC_ISS-T_YNG_GY4 Ground Control | 20 Weeks RRRM2_BRN_GC_ISS-T_YNG_GY4 HGC-ISS-04 Mus musculus NCBITAXON http://purl.bioontology.org/ontology/NCBITAXON/10090 C57BL/6NTac EFO http://www.ebi.ac.uk/efo/EFO_0020093 Wild Type NCIT http://purl.obolibrary.org/obo/NCIT_C62195 Taconic Biosciences Female MESH http://purl.bioontology.org/ontology/MESH/D005260 Ground Control OSD https://osdr.nasa.gov/ 12 week UO http://purl.obolibrary.org/obo/UO_0000034 Left cerebral hemisphere FMA http://purl.org/sig/ont/fma/fma61819 Nutrient Upgraded Rodent Food Bar (NuRFB) ad libitum 20 week UO http://purl.obolibrary.org/obo/UO_0000034 Animal Husbandry Rodent Flight Hardware (Transporter and Habitat) Hut 53 day UO http://purl.obolibrary.org/obo/UO_0000033 12 h light/dark cycle sample collection Bilateral thoracotomy with sedation, Cardiac puncture with sedation, Ketamine/xylazine injection Liquid Nitrogen NCIT http://purl.obolibrary.org/obo/NCIT_C68796 -80 degree Celsius UO http://purl.obolibrary.org/obo/UO_0000027 6E2A671967 18-Sep-2019 1149.0 8542 {'min_max_genes': [321.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [4... 2527 3241.278564 7.835184 8.084032 7.211684 0.222495 2.105558 9.091643 0.280496 2.311708 0.000000 0.000000 0.000000 6688.0 2614 0.004741 False 6 Neuron Neuron 6 Neuron {'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50} Neuron {'col_celltype': 'annotation_by_markers_individual_heterogeneous_collapsed', 'flavor': 'scanvi',... 0 0.0075 15 1.8 0,1 0.005 Neuron L6 CT CTX Glut 12 Weeks 20 Weeks Ground Control Excitatory 030 L6 CT CTX Glut 030 L6 CT CTX Glut 0.995661 Glutamatergic 0 0 Neuron Neurons
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
TTTGTGTTCCCTGATC-1_RRRM2_BRN_FLT_ISS-T_YNG_FY5 Space Flight | 20 Weeks RRRM2_BRN_FLT_ISS-T_YNG_FY5 FL-ISS-05 Mus musculus NCBITAXON http://purl.bioontology.org/ontology/NCBITAXON/10090 C57BL/6NTac EFO http://www.ebi.ac.uk/efo/EFO_0020093 Wild Type NCIT http://purl.obolibrary.org/obo/NCIT_C62195 Taconic Biosciences Female MESH http://purl.bioontology.org/ontology/MESH/D005260 Space Flight MESH http://purl.bioontology.org/ontology/MESH/D013026 12 week UO http://purl.obolibrary.org/obo/UO_0000034 Left cerebral hemisphere FMA http://purl.org/sig/ont/fma/fma61819 Nutrient Upgraded Rodent Food Bar (NuRFB) ad libitum 20 week UO http://purl.obolibrary.org/obo/UO_0000034 Animal Husbandry Rodent Flight Hardware (Transporter and Habitat) Hut 53 day UO http://purl.obolibrary.org/obo/UO_0000033 12 h light/dark cycle sample collection Bilateral thoracotomy with sedation, Cardiac puncture with sedation, Ketamine/xylazine injection Cryochiller OSD https://osdr.nasa.gov/ -80 degree Celsius UO http://purl.obolibrary.org/obo/UO_0000027 6E3E102A12 16-Sep-2019 885.0 4714 {'min_max_genes': [809.825, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': ... 3951 3733.228760 8.281977 8.225297 15.281790 0.409345 2.790047 32.756115 0.877420 3.519162 0.000000 0.000000 0.000000 12819.0 4151 0.006702 False 6 Neuron Neuron 6 Neuron {'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50} Neuron {'col_celltype': 'annotation_by_markers_individual_heterogeneous_collapsed', 'flavor': 'scanvi',... 0 0.0075 15 1.8 0,1 0.005 Neuron L6 CT CTX Glut 12 Weeks 20 Weeks Space Flight Excitatory 030 L6 CT CTX Glut 030 L6 CT CTX Glut 0.659047 Glutamatergic 1 0 Neuron Neurons
TTTGTGTTCCGTAAAC-1_RRRM2_BRN_FLT_ISS-T_YNG_FY5 Space Flight | 20 Weeks RRRM2_BRN_FLT_ISS-T_YNG_FY5 FL-ISS-05 Mus musculus NCBITAXON http://purl.bioontology.org/ontology/NCBITAXON/10090 C57BL/6NTac EFO http://www.ebi.ac.uk/efo/EFO_0020093 Wild Type NCIT http://purl.obolibrary.org/obo/NCIT_C62195 Taconic Biosciences Female MESH http://purl.bioontology.org/ontology/MESH/D005260 Space Flight MESH http://purl.bioontology.org/ontology/MESH/D013026 12 week UO http://purl.obolibrary.org/obo/UO_0000034 Left cerebral hemisphere FMA http://purl.org/sig/ont/fma/fma61819 Nutrient Upgraded Rodent Food Bar (NuRFB) ad libitum 20 week UO http://purl.obolibrary.org/obo/UO_0000034 Animal Husbandry Rodent Flight Hardware (Transporter and Habitat) Hut 53 day UO http://purl.obolibrary.org/obo/UO_0000033 12 h light/dark cycle sample collection Bilateral thoracotomy with sedation, Cardiac puncture with sedation, Ketamine/xylazine injection Cryochiller OSD https://osdr.nasa.gov/ -80 degree Celsius UO http://purl.obolibrary.org/obo/UO_0000027 6E3E102A12 16-Sep-2019 885.0 4714 {'min_max_genes': [809.825, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': ... 4371 3886.233643 8.382976 8.265453 10.151247 0.261210 2.411551 47.056725 1.210857 3.872382 0.505784 0.013015 0.409313 15502.0 4645 0.007560 False 5 Neuron Neuron 5 Neuron {'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50} Neuron {'col_celltype': 'annotation_by_markers_individual_heterogeneous_collapsed', 'flavor': 'scanvi',... 0 0.0075 15 1.8 0,2 0.005 Neuron CA1-ProS Glut 12 Weeks 20 Weeks Space Flight Excitatory 016 CA1-ProS Glut 016 CA1-ProS Glut 0.028035 Glutamatergic 1 0 Neuron Neurons
TTTGTGTTCTGTGCAG-1_RRRM2_BRN_FLT_ISS-T_YNG_FY5 Space Flight | 20 Weeks RRRM2_BRN_FLT_ISS-T_YNG_FY5 FL-ISS-05 Mus musculus NCBITAXON http://purl.bioontology.org/ontology/NCBITAXON/10090 C57BL/6NTac EFO http://www.ebi.ac.uk/efo/EFO_0020093 Wild Type NCIT http://purl.obolibrary.org/obo/NCIT_C62195 Taconic Biosciences Female MESH http://purl.bioontology.org/ontology/MESH/D005260 Space Flight MESH http://purl.bioontology.org/ontology/MESH/D013026 12 week UO http://purl.obolibrary.org/obo/UO_0000034 Left cerebral hemisphere FMA http://purl.org/sig/ont/fma/fma61819 Nutrient Upgraded Rodent Food Bar (NuRFB) ad libitum 20 week UO http://purl.obolibrary.org/obo/UO_0000034 Animal Husbandry Rodent Flight Hardware (Transporter and Habitat) Hut 53 day UO http://purl.obolibrary.org/obo/UO_0000033 12 h light/dark cycle sample collection Bilateral thoracotomy with sedation, Cardiac puncture with sedation, Ketamine/xylazine injection Cryochiller OSD https://osdr.nasa.gov/ -80 degree Celsius UO http://purl.obolibrary.org/obo/UO_0000027 6E3E102A12 16-Sep-2019 885.0 4714 {'min_max_genes': [809.825, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': ... 5541 3894.054932 8.620111 8.267463 17.510311 0.449668 2.918328 28.229233 0.724932 3.375169 0.000000 0.000000 0.000000 27623.0 5886 0.035294 False 1 Neuron Neuron 1 Neuron {'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50} Neuron {'col_celltype': 'annotation_by_markers_individual_heterogeneous_collapsed', 'flavor': 'scanvi',... 0 0.0075 15 1.8 0,0 0.005 Neuron L4/5 IT CTX Glut 12 Weeks 20 Weeks Space Flight Excitatory 006 L4/5 IT CTX Glut 006 L4/5 IT CTX Glut 0.832242 Glutamatergic 1 0 Neuron Neurons
TTTGTTGGTGTTAGCA-1_RRRM2_BRN_FLT_ISS-T_YNG_FY5 Space Flight | 20 Weeks RRRM2_BRN_FLT_ISS-T_YNG_FY5 FL-ISS-05 Mus musculus NCBITAXON http://purl.bioontology.org/ontology/NCBITAXON/10090 C57BL/6NTac EFO http://www.ebi.ac.uk/efo/EFO_0020093 Wild Type NCIT http://purl.obolibrary.org/obo/NCIT_C62195 Taconic Biosciences Female MESH http://purl.bioontology.org/ontology/MESH/D005260 Space Flight MESH http://purl.bioontology.org/ontology/MESH/D013026 12 week UO http://purl.obolibrary.org/obo/UO_0000034 Left cerebral hemisphere FMA http://purl.org/sig/ont/fma/fma61819 Nutrient Upgraded Rodent Food Bar (NuRFB) ad libitum 20 week UO http://purl.obolibrary.org/obo/UO_0000034 Animal Husbandry Rodent Flight Hardware (Transporter and Habitat) Hut 53 day UO http://purl.obolibrary.org/obo/UO_0000033 12 h light/dark cycle sample collection Bilateral thoracotomy with sedation, Cardiac puncture with sedation, Ketamine/xylazine injection Cryochiller OSD https://osdr.nasa.gov/ -80 degree Celsius UO http://purl.obolibrary.org/obo/UO_0000027 6E3E102A12 16-Sep-2019 885.0 4714 {'min_max_genes': [809.825, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': ... 845 1936.500610 6.740519 7.569154 24.934469 1.287604 3.255573 28.834591 1.489005 3.395669 0.000000 0.000000 0.000000 1469.0 873 0.007560 False 11 Oligodendrocyte Oligodendrocyte 11 Oligodendrocyte {'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50} Oligodendrocyte {'col_celltype': 'annotation_by_markers_individual_heterogeneous_collapsed', 'flavor': 'scanvi',... 3 0.0075 15 1.8 3 0.005 Oligodendrocyte Oligo NN 12 Weeks 20 Weeks Space Flight Oligodendrocyte 327 Oligo NN 327 Oligo NN 0.993962 Oligodendrocyte 1 0 Oligodendrocyte Macroglia
TTTGTTGGTTAAGTGT-1_RRRM2_BRN_FLT_ISS-T_YNG_FY5 Space Flight | 20 Weeks RRRM2_BRN_FLT_ISS-T_YNG_FY5 FL-ISS-05 Mus musculus NCBITAXON http://purl.bioontology.org/ontology/NCBITAXON/10090 C57BL/6NTac EFO http://www.ebi.ac.uk/efo/EFO_0020093 Wild Type NCIT http://purl.obolibrary.org/obo/NCIT_C62195 Taconic Biosciences Female MESH http://purl.bioontology.org/ontology/MESH/D005260 Space Flight MESH http://purl.bioontology.org/ontology/MESH/D013026 12 week UO http://purl.obolibrary.org/obo/UO_0000034 Left cerebral hemisphere FMA http://purl.org/sig/ont/fma/fma61819 Nutrient Upgraded Rodent Food Bar (NuRFB) ad libitum 20 week UO http://purl.obolibrary.org/obo/UO_0000034 Animal Husbandry Rodent Flight Hardware (Transporter and Habitat) Hut 53 day UO http://purl.obolibrary.org/obo/UO_0000033 12 h light/dark cycle sample collection Bilateral thoracotomy with sedation, Cardiac puncture with sedation, Ketamine/xylazine injection Cryochiller OSD https://osdr.nasa.gov/ -80 degree Celsius UO http://purl.obolibrary.org/obo/UO_0000027 6E3E102A12 16-Sep-2019 885.0 4714 {'min_max_genes': [809.825, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': ... 3268 3615.137207 8.092239 8.193162 7.901684 0.218572 2.186240 28.523968 0.789015 3.385202 1.162011 0.032143 0.771039 9258.0 3411 0.058924 False 1 Neuron Neuron 1 Neuron {'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50} Neuron {'col_celltype': 'annotation_by_markers_individual_heterogeneous_collapsed', 'flavor': 'scanvi',... 0 0.0075 15 1.8 0,0 0.005 Neuron L4/5 IT CTX Glut 12 Weeks 20 Weeks Space Flight Excitatory 006 L4/5 IT CTX Glut 006 L4/5 IT CTX Glut 0.964018 Glutamatergic 1 0 Neuron Neurons

103274 rows × 99 columns

Data Descriptives¶

In [2]:
%matplotlib inline

# Detect Metadata Columns in AnnData Object
metadata_cols = self.rna.obs.groupby(col_sample).apply(
    lambda x: list(x.columns[np.where(
        x.apply(lambda y: len(y.unique()) ==  1))[0]]))
metadata_cols = [x for x in metadata_cols.explode().unique() if all((
    x in metadata_cols.loc[i] for i in metadata_cols.index.values))]

# Value Counts for Categorical Variables
metadata_cols_category = self.rna.obs[metadata_cols].dtypes[((
    self.rna.obs[metadata_cols].dtypes == "category") | (self.rna.obs[
        metadata_cols].apply(lambda x: len(x.unique()) < 6))) & (self.rna.obs[
            metadata_cols].apply(lambda x: len(x.unique()) > 1))].index
for x in metadata_cols_category:
    print(x, "\n\n", self.rna.obs[x].value_counts(), "\n\n")
    if col_batch is not None:  # by batch
        if x != col_batch:
            print(x, "\n\n", self.rna.obs[[x, col_batch]].groupby(
                col_batch).value_counts(), "\n\n")

# Descriptives for Continuous Variables
print(self.rna.obs[self.rna.obs.columns.difference(
    metadata_cols_category)].describe())
if col_batch is not None:  # by batch
    print(self.rna.obs[list(self.rna.obs.columns.difference(
        metadata_cols_category)) + [col_batch]].groupby(col_batch).describe())

# Cells per Cluster
perc_clusters = round(100 * self.rna.obs.groupby(col_sample).value_counts(
    [col_celltype], normalize=True).unstack(1), 2)
print(f"\n\n*** Cell Composition (%) ***\n\n{perc_clusters}")

# Number of Cells
n_cells = self.rna.obs.groupby(col_sample).apply(
    lambda x: x.n_cells_original_sample.unique()[0],
    include_groups=False).to_frame("Original Cell N").join(
        self.rna.obs.groupby(col_sample).apply(
            lambda x: x.shape[0], include_groups=False).to_frame("N Cells"))
n_cells.loc[:, "Percent_Filtered"] = round(100 * (1 - n_cells[
    "N Cells"] / n_cells["Original Cell N"]), 2)
print("\n\n", n_cells.sort_values("Percent_Filtered"))
/tmp/ipykernel_919320/1416146960.py:4: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.
  metadata_cols = self.rna.obs.groupby(col_sample).apply(
Group 

 Group
Ground Control | 37 Weeks    35362
Ground Control | 20 Weeks    31600
Space Flight | 37 Weeks      19904
Space Flight | 20 Weeks      16408
Name: count, dtype: int64 


sample 

 sample
RRRM2_BRN_GC_ISS-T_OLD_GO16     18386
RRRM2_BRN_GC_ISS-T_YNG_GY2       9651
RRRM2_BRN_GC_ISS-T_YNG_GY4       7547
RRRM2_BRN_GC_ISS-T_OLD_GO19      7539
RRRM2_BRN_GC_ISS-T_OLD_GO18      5842
RRRM2_BRN_FLT_ISS-T_OLD_FO19     5747
RRRM2_BRN_GC_ISS-T_YNG_GY9       5465
RRRM2_BRN_GC_ISS-T_YNG_GY7       5265
RRRM2_BRN_FLT_ISS-T_YNG_FY8      5095
RRRM2_BRN_FLT_ISS-T_OLD_FO20     4922
RRRM2_BRN_FLT_ISS-T_OLD_FO16     4050
RRRM2_BRN_FLT_ISS-T_YNG_FY5      3914
RRRM2_BRN_FLT_ISS-T_OLD_FO14     3864
RRRM2_BRN_FLT_ISS-T_YNG_FY2      3730
RRRM2_BRN_GC_ISS-T_YNG_GY1       3672
RRRM2_BRN_FLT_ISS-T_YNG_FY7      3669
RRRM2_BRN_GC_ISS-T_OLD_GO13      3595
RRRM2_BRN_FLT_ISS-T_OLD_FO17     1321
Name: count, dtype: int64 


sample 

 Group                      sample                      
Ground Control | 20 Weeks  RRRM2_BRN_GC_ISS-T_YNG_GY2       9651
                           RRRM2_BRN_GC_ISS-T_YNG_GY4       7547
                           RRRM2_BRN_GC_ISS-T_YNG_GY9       5465
                           RRRM2_BRN_GC_ISS-T_YNG_GY7       5265
                           RRRM2_BRN_GC_ISS-T_YNG_GY1       3672
                           RRRM2_BRN_GC_ISS-T_OLD_GO18         0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO20        0
                           RRRM2_BRN_GC_ISS-T_OLD_GO19         0
                           RRRM2_BRN_GC_ISS-T_OLD_GO13         0
                           RRRM2_BRN_FLT_ISS-T_YNG_FY8         0
                           RRRM2_BRN_FLT_ISS-T_YNG_FY7         0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO19        0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO14        0
                           RRRM2_BRN_FLT_ISS-T_YNG_FY2         0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO17        0
                           RRRM2_BRN_GC_ISS-T_OLD_GO16         0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO16        0
                           RRRM2_BRN_FLT_ISS-T_YNG_FY5         0
Ground Control | 37 Weeks  RRRM2_BRN_GC_ISS-T_OLD_GO16     18386
                           RRRM2_BRN_GC_ISS-T_OLD_GO19      7539
                           RRRM2_BRN_GC_ISS-T_OLD_GO18      5842
                           RRRM2_BRN_GC_ISS-T_OLD_GO13      3595
                           RRRM2_BRN_GC_ISS-T_YNG_GY4          0
                           RRRM2_BRN_GC_ISS-T_YNG_GY9          0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO20        0
                           RRRM2_BRN_FLT_ISS-T_YNG_FY8         0
                           RRRM2_BRN_FLT_ISS-T_YNG_FY7         0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO19        0
                           RRRM2_BRN_GC_ISS-T_YNG_GY7          0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO14        0
                           RRRM2_BRN_GC_ISS-T_YNG_GY1          0
                           RRRM2_BRN_FLT_ISS-T_YNG_FY2         0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO17        0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO16        0
                           RRRM2_BRN_GC_ISS-T_YNG_GY2          0
                           RRRM2_BRN_FLT_ISS-T_YNG_FY5         0
Space Flight | 20 Weeks    RRRM2_BRN_FLT_ISS-T_YNG_FY8      5095
                           RRRM2_BRN_FLT_ISS-T_YNG_FY5      3914
                           RRRM2_BRN_FLT_ISS-T_YNG_FY2      3730
                           RRRM2_BRN_FLT_ISS-T_YNG_FY7      3669
                           RRRM2_BRN_GC_ISS-T_YNG_GY4          0
                           RRRM2_BRN_GC_ISS-T_YNG_GY9          0
                           RRRM2_BRN_GC_ISS-T_OLD_GO18         0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO20        0
                           RRRM2_BRN_GC_ISS-T_OLD_GO19         0
                           RRRM2_BRN_GC_ISS-T_OLD_GO13         0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO19        0
                           RRRM2_BRN_GC_ISS-T_YNG_GY7          0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO14        0
                           RRRM2_BRN_GC_ISS-T_YNG_GY1          0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO17        0
                           RRRM2_BRN_GC_ISS-T_OLD_GO16         0
                           RRRM2_BRN_FLT_ISS-T_OLD_FO16        0
                           RRRM2_BRN_GC_ISS-T_YNG_GY2          0
Space Flight | 37 Weeks    RRRM2_BRN_FLT_ISS-T_OLD_FO19     5747
                           RRRM2_BRN_FLT_ISS-T_OLD_FO20     4922
                           RRRM2_BRN_FLT_ISS-T_OLD_FO16     4050
                           RRRM2_BRN_FLT_ISS-T_OLD_FO14     3864
                           RRRM2_BRN_FLT_ISS-T_OLD_FO17     1321
                           RRRM2_BRN_GC_ISS-T_YNG_GY4          0
                           RRRM2_BRN_GC_ISS-T_YNG_GY9          0
                           RRRM2_BRN_GC_ISS-T_OLD_GO18         0
                           RRRM2_BRN_GC_ISS-T_OLD_GO19         0
                           RRRM2_BRN_GC_ISS-T_OLD_GO13         0
                           RRRM2_BRN_FLT_ISS-T_YNG_FY8         0
                           RRRM2_BRN_FLT_ISS-T_YNG_FY7         0
                           RRRM2_BRN_GC_ISS-T_YNG_GY7          0
                           RRRM2_BRN_GC_ISS-T_YNG_GY1          0
                           RRRM2_BRN_FLT_ISS-T_YNG_FY2         0
                           RRRM2_BRN_GC_ISS-T_OLD_GO16         0
                           RRRM2_BRN_GC_ISS-T_YNG_GY2          0
                           RRRM2_BRN_FLT_ISS-T_YNG_FY5         0
Name: count, dtype: int64 


Sample Number 

 Sample Number
HGC-ISS-16    18386
HGC-ISS-02     9651
HGC-ISS-04     7547
HGC-ISS-19     7539
HGC-ISS-18     5842
FL-ISS-19      5747
HGC-ISS-09     5465
HGC-ISS-07     5265
FL-ISS-08      5095
FL-ISS-20      4922
FL-ISS-16      4050
FL-ISS-05      3914
FL-ISS-14      3864
FL-ISS-02      3730
HGC-ISS-01     3672
FL-ISS-07      3669
HGC-ISS-13     3595
FL-ISS-17      1321
Name: count, dtype: int64 


Sample Number 

 Group                      Sample Number
Ground Control | 20 Weeks  HGC-ISS-02        9651
                           HGC-ISS-04        7547
                           HGC-ISS-09        5465
                           HGC-ISS-07        5265
                           HGC-ISS-01        3672
                           FL-ISS-02            0
                           FL-ISS-05            0
                           FL-ISS-07            0
                           FL-ISS-08            0
                           FL-ISS-14            0
                           FL-ISS-16            0
                           FL-ISS-17            0
                           FL-ISS-19            0
                           FL-ISS-20            0
                           HGC-ISS-13           0
                           HGC-ISS-16           0
                           HGC-ISS-18           0
                           HGC-ISS-19           0
Ground Control | 37 Weeks  HGC-ISS-16       18386
                           HGC-ISS-19        7539
                           HGC-ISS-18        5842
                           HGC-ISS-13        3595
                           FL-ISS-02            0
                           FL-ISS-05            0
                           FL-ISS-07            0
                           FL-ISS-08            0
                           FL-ISS-14            0
                           FL-ISS-16            0
                           FL-ISS-17            0
                           FL-ISS-19            0
                           FL-ISS-20            0
                           HGC-ISS-01           0
                           HGC-ISS-02           0
                           HGC-ISS-04           0
                           HGC-ISS-07           0
                           HGC-ISS-09           0
Space Flight | 20 Weeks    FL-ISS-08         5095
                           FL-ISS-05         3914
                           FL-ISS-02         3730
                           FL-ISS-07         3669
                           FL-ISS-14            0
                           FL-ISS-16            0
                           FL-ISS-17            0
                           FL-ISS-19            0
                           FL-ISS-20            0
                           HGC-ISS-01           0
                           HGC-ISS-02           0
                           HGC-ISS-04           0
                           HGC-ISS-07           0
                           HGC-ISS-09           0
                           HGC-ISS-13           0
                           HGC-ISS-16           0
                           HGC-ISS-18           0
                           HGC-ISS-19           0
Space Flight | 37 Weeks    FL-ISS-19         5747
                           FL-ISS-20         4922
                           FL-ISS-16         4050
                           FL-ISS-14         3864
                           FL-ISS-17         1321
                           FL-ISS-02            0
                           FL-ISS-05            0
                           FL-ISS-07            0
                           FL-ISS-08            0
                           HGC-ISS-01           0
                           HGC-ISS-02           0
                           HGC-ISS-04           0
                           HGC-ISS-07           0
                           HGC-ISS-09           0
                           HGC-ISS-13           0
                           HGC-ISS-16           0
                           HGC-ISS-18           0
                           HGC-ISS-19           0
Name: count, dtype: int64 


Factor Value[Spaceflight] 

 Factor Value[Spaceflight]
Ground Control    66962
Space Flight      36312
Name: count, dtype: int64 


Factor Value[Spaceflight] 

 Group                      Factor Value[Spaceflight]
Ground Control | 20 Weeks  Ground Control               31600
                           Space Flight                     0
Ground Control | 37 Weeks  Ground Control               35362
                           Space Flight                     0
Space Flight | 20 Weeks    Space Flight                 16408
                           Ground Control                   0
Space Flight | 37 Weeks    Space Flight                 19904
                           Ground Control                   0
Name: count, dtype: int64 


Term Source REF.4 

 Term Source REF.4
OSD     66962
MESH    36312
Name: count, dtype: int64 


Term Source REF.4 

 Group                      Term Source REF.4
Ground Control | 20 Weeks  OSD                  31600
                           MESH                     0
Ground Control | 37 Weeks  OSD                  35362
                           MESH                     0
Space Flight | 20 Weeks    MESH                 16408
                           OSD                      0
Space Flight | 37 Weeks    MESH                 19904
                           OSD                      0
Name: count, dtype: int64 


Term Accession Number.4 

 Term Accession Number.4
https://osdr.nasa.gov/                               66962
http://purl.bioontology.org/ontology/MESH/D013026    36312
Name: count, dtype: int64 


Term Accession Number.4 

 Group                      Term Accession Number.4                          
Ground Control | 20 Weeks  https://osdr.nasa.gov/                               31600
                           http://purl.bioontology.org/ontology/MESH/D013026        0
Ground Control | 37 Weeks  https://osdr.nasa.gov/                               35362
                           http://purl.bioontology.org/ontology/MESH/D013026        0
Space Flight | 20 Weeks    http://purl.bioontology.org/ontology/MESH/D013026    16408
                           https://osdr.nasa.gov/                                   0
Space Flight | 37 Weeks    http://purl.bioontology.org/ontology/MESH/D013026    19904
                           https://osdr.nasa.gov/                                   0
Name: count, dtype: int64 


Factor Value[Age] 

 Factor Value[Age]
29    55266
12    48008
Name: count, dtype: int64 


Factor Value[Age] 

 Group                      Factor Value[Age]
Ground Control | 20 Weeks  12                   31600
                           29                       0
Ground Control | 37 Weeks  29                   35362
                           12                       0
Space Flight | 20 Weeks    12                   16408
                           29                       0
Space Flight | 37 Weeks    29                   19904
                           12                       0
Name: count, dtype: int64 


Characteristics[Age at Euthanasia] 

 Characteristics[Age at Euthanasia]
37    55266
20    48008
Name: count, dtype: int64 


Characteristics[Age at Euthanasia] 

 Group                      Characteristics[Age at Euthanasia]
Ground Control | 20 Weeks  20                                    31600
                           37                                        0
Ground Control | 37 Weeks  37                                    35362
                           20                                        0
Space Flight | 20 Weeks    20                                    16408
                           37                                        0
Space Flight | 37 Weeks    37                                    19904
                           20                                        0
Name: count, dtype: int64 


Parameter Value[Sample Preservation Method] 

 Parameter Value[Sample Preservation Method]
Liquid Nitrogen    66962
Cryochiller        36312
Name: count, dtype: int64 


Parameter Value[Sample Preservation Method] 

 Group                      Parameter Value[Sample Preservation Method]
Ground Control | 20 Weeks  Liquid Nitrogen                                31600
                           Cryochiller                                        0
Ground Control | 37 Weeks  Liquid Nitrogen                                35362
                           Cryochiller                                        0
Space Flight | 20 Weeks    Cryochiller                                    16408
                           Liquid Nitrogen                                    0
Space Flight | 37 Weeks    Cryochiller                                    19904
                           Liquid Nitrogen                                    0
Name: count, dtype: int64 


Term Source REF.9 

 Term Source REF.9
NCIT    66962
OSD     36312
Name: count, dtype: int64 


Term Source REF.9 

 Group                      Term Source REF.9
Ground Control | 20 Weeks  NCIT                 31600
                           OSD                      0
Ground Control | 37 Weeks  NCIT                 35362
                           OSD                      0
Space Flight | 20 Weeks    OSD                  16408
                           NCIT                     0
Space Flight | 37 Weeks    OSD                  19904
                           NCIT                     0
Name: count, dtype: int64 


Term Accession Number.9 

 Term Accession Number.9
http://purl.obolibrary.org/obo/NCIT_C68796    66962
https://osdr.nasa.gov/                        36312
Name: count, dtype: int64 


Term Accession Number.9 

 Group                      Term Accession Number.9                   
Ground Control | 20 Weeks  http://purl.obolibrary.org/obo/NCIT_C68796    31600
                           https://osdr.nasa.gov/                            0
Ground Control | 37 Weeks  http://purl.obolibrary.org/obo/NCIT_C68796    35362
                           https://osdr.nasa.gov/                            0
Space Flight | 20 Weeks    https://osdr.nasa.gov/                        16408
                           http://purl.obolibrary.org/obo/NCIT_C68796        0
Space Flight | 37 Weeks    https://osdr.nasa.gov/                        19904
                           http://purl.obolibrary.org/obo/NCIT_C68796        0
Name: count, dtype: int64 


Comment[RFID] 

 Comment[RFID]
6E35413D61    18386
6E371E2032     9651
6E2A671967     7547
6E3C342F47     7539
6E3C216122     5842
6E3D2C2D2C     5747
6E3C705065     5465
6E28536840     5265
6E3C42091B     5095
6E272D285A     4922
6E27313758     4050
6E3E102A12     3914
6E2A180C12     3864
6E394B6C23     3730
6E28307F36     3672
6E3E325E7C     3669
6E3A3C1239     3595
6E353B735A     1321
Name: count, dtype: int64 


Comment[RFID] 

 Group                      Comment[RFID]
Ground Control | 20 Weeks  6E371E2032        9651
                           6E2A671967        7547
                           6E3C705065        5465
                           6E28536840        5265
                           6E28307F36        3672
                           6E2A180C12           0
                           6E3A3C1239           0
                           6E3C342F47           0
                           6E3C42091B           0
                           6E3C216122           0
                           6E3D2C2D2C           0
                           6E3E102A12           0
                           6E3E325E7C           0
                           6E272D285A           0
                           6E353B735A           0
                           6E394B6C23           0
                           6E35413D61           0
                           6E27313758           0
Ground Control | 37 Weeks  6E35413D61       18386
                           6E3C342F47        7539
                           6E3C216122        5842
                           6E3A3C1239        3595
                           6E2A180C12           0
                           6E2A671967           0
                           6E3C42091B           0
                           6E3C705065           0
                           6E3D2C2D2C           0
                           6E3E102A12           0
                           6E3E325E7C           0
                           6E272D285A           0
                           6E353B735A           0
                           6E371E2032           0
                           6E394B6C23           0
                           6E28307F36           0
                           6E27313758           0
                           6E28536840           0
Space Flight | 20 Weeks    6E3C42091B        5095
                           6E3E102A12        3914
                           6E394B6C23        3730
                           6E3E325E7C        3669
                           6E2A180C12           0
                           6E2A671967           0
                           6E3A3C1239           0
                           6E3C342F47           0
                           6E3C216122           0
                           6E3C705065           0
                           6E3D2C2D2C           0
                           6E272D285A           0
                           6E353B735A           0
                           6E371E2032           0
                           6E28307F36           0
                           6E35413D61           0
                           6E27313758           0
                           6E28536840           0
Space Flight | 37 Weeks    6E3D2C2D2C        5747
                           6E272D285A        4922
                           6E27313758        4050
                           6E2A180C12        3864
                           6E353B735A        1321
                           6E2A671967           0
                           6E3A3C1239           0
                           6E3C342F47           0
                           6E3C42091B           0
                           6E3C216122           0
                           6E3C705065           0
                           6E3E102A12           0
                           6E3E325E7C           0
                           6E371E2032           0
                           6E394B6C23           0
                           6E28307F36           0
                           6E35413D61           0
                           6E28536840           0
Name: count, dtype: int64 


Comment[Euthanasia Date] 

 Comment[Euthanasia Date]
20-Sep-2019    31767
18-Sep-2019    29999
19-Sep-2019    25100
17-Sep-2019     8764
16-Sep-2019     7644
Name: count, dtype: int64 


Comment[Euthanasia Date] 

 Group                      Comment[Euthanasia Date]
Ground Control | 20 Weeks  18-Sep-2019                 26135
                           19-Sep-2019                  5465
                           16-Sep-2019                     0
                           17-Sep-2019                     0
                           20-Sep-2019                     0
Ground Control | 37 Weeks  20-Sep-2019                 31767
                           19-Sep-2019                  3595
                           16-Sep-2019                     0
                           17-Sep-2019                     0
                           18-Sep-2019                     0
Space Flight | 20 Weeks    17-Sep-2019                  8764
                           16-Sep-2019                  7644
                           18-Sep-2019                     0
                           19-Sep-2019                     0
                           20-Sep-2019                     0
Space Flight | 37 Weeks    19-Sep-2019                 16040
                           18-Sep-2019                  3864
                           16-Sep-2019                     0
                           17-Sep-2019                     0
                           20-Sep-2019                     0
Name: count, dtype: int64 


kws_pp_sample 

 kws_pp_sample
{'min_max_genes': [201.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [300, 10018.199999999983], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                  18386
{'min_max_genes': [507.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [696.45, 23662.899999999972], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                9651
{'min_max_genes': [321.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [414.0, 11122.175000000005], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                 7547
{'min_max_genes': [666.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [942.0, 21190.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                            7539
{'min_max_genes': [326.1, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [422.1, 13468.399999999998], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                 5842
{'min_max_genes': [200, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [300, 14724.999999999998], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                     5747
{'min_max_genes': [703.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1006.1500000000001, 23784.40000000001], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}     5465
{'min_max_genes': [798.75, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1176.375, 28050.25], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                       5265
{'min_max_genes': [481.425, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [681.7, 27907.149999999994], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}               5095
{'min_max_genes': [628.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [895.0, 19711.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                            4922
{'min_max_genes': [766.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1213.2, 36130.25], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                          4050
{'min_max_genes': [809.825, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1300.3, 32231.825000000015], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}              3914
{'min_max_genes': [719.475, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1128.9, 33910.62499999997], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}               3864
{'min_max_genes': [700.2, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1087.2, 35338.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                           3730
{'min_max_genes': [923.4000000000001, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1489.7, 37456.77499999999], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}     3672
{'min_max_genes': [331.925, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [452.77500000000003, 13453.3], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}             3669
{'min_max_genes': [822.975, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1282.925, 23156.550000000007], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}            3595
{'min_max_genes': [316.3, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [376.3, 11766.900000000009], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                 1321
Name: count, dtype: int64 


kws_pp_sample 

 Group                      kws_pp_sample                                                                                                                                                                                                                                        
Ground Control | 20 Weeks  {'min_max_genes': [507.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [696.45, 23662.899999999972], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                9651
                           {'min_max_genes': [321.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [414.0, 11122.175000000005], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                 7547
                           {'min_max_genes': [703.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1006.1500000000001, 23784.40000000001], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}     5465
                           {'min_max_genes': [798.75, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1176.375, 28050.25], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                       5265
                           {'min_max_genes': [923.4000000000001, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1489.7, 37456.77499999999], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}     3672
                           {'min_max_genes': [200, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [300, 14724.999999999998], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                        0
                           {'min_max_genes': [201.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [300, 10018.199999999983], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                      0
                           {'min_max_genes': [316.3, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [376.3, 11766.900000000009], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                    0
                           {'min_max_genes': [326.1, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [422.1, 13468.399999999998], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                    0
                           {'min_max_genes': [331.925, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [452.77500000000003, 13453.3], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                0
                           {'min_max_genes': [481.425, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [681.7, 27907.149999999994], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                  0
                           {'min_max_genes': [628.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [895.0, 19711.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                               0
                           {'min_max_genes': [666.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [942.0, 21190.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                               0
                           {'min_max_genes': [700.2, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1087.2, 35338.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                              0
                           {'min_max_genes': [719.475, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1128.9, 33910.62499999997], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                  0
                           {'min_max_genes': [766.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1213.2, 36130.25], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                             0
                           {'min_max_genes': [809.825, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1300.3, 32231.825000000015], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                 0
                           {'min_max_genes': [822.975, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1282.925, 23156.550000000007], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}               0
Ground Control | 37 Weeks  {'min_max_genes': [201.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [300, 10018.199999999983], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                  18386
                           {'min_max_genes': [666.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [942.0, 21190.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                            7539
                           {'min_max_genes': [326.1, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [422.1, 13468.399999999998], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                 5842
                           {'min_max_genes': [822.975, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1282.925, 23156.550000000007], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}            3595
                           {'min_max_genes': [200, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [300, 14724.999999999998], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                        0
                           {'min_max_genes': [316.3, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [376.3, 11766.900000000009], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                    0
                           {'min_max_genes': [321.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [414.0, 11122.175000000005], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                    0
                           {'min_max_genes': [331.925, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [452.77500000000003, 13453.3], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                0
                           {'min_max_genes': [481.425, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [681.7, 27907.149999999994], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                  0
                           {'min_max_genes': [507.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [696.45, 23662.899999999972], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                   0
                           {'min_max_genes': [628.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [895.0, 19711.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                               0
                           {'min_max_genes': [700.2, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1087.2, 35338.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                              0
                           {'min_max_genes': [703.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1006.1500000000001, 23784.40000000001], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}        0
                           {'min_max_genes': [719.475, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1128.9, 33910.62499999997], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                  0
                           {'min_max_genes': [766.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1213.2, 36130.25], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                             0
                           {'min_max_genes': [798.75, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1176.375, 28050.25], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                          0
                           {'min_max_genes': [809.825, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1300.3, 32231.825000000015], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                 0
                           {'min_max_genes': [923.4000000000001, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1489.7, 37456.77499999999], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}        0
Space Flight | 20 Weeks    {'min_max_genes': [481.425, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [681.7, 27907.149999999994], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}               5095
                           {'min_max_genes': [809.825, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1300.3, 32231.825000000015], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}              3914
                           {'min_max_genes': [700.2, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1087.2, 35338.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                           3730
                           {'min_max_genes': [331.925, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [452.77500000000003, 13453.3], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}             3669
                           {'min_max_genes': [200, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [300, 14724.999999999998], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                        0
                           {'min_max_genes': [201.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [300, 10018.199999999983], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                      0
                           {'min_max_genes': [316.3, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [376.3, 11766.900000000009], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                    0
                           {'min_max_genes': [321.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [414.0, 11122.175000000005], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                    0
                           {'min_max_genes': [326.1, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [422.1, 13468.399999999998], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                    0
                           {'min_max_genes': [507.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [696.45, 23662.899999999972], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                   0
                           {'min_max_genes': [628.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [895.0, 19711.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                               0
                           {'min_max_genes': [666.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [942.0, 21190.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                               0
                           {'min_max_genes': [703.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1006.1500000000001, 23784.40000000001], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}        0
                           {'min_max_genes': [719.475, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1128.9, 33910.62499999997], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                  0
                           {'min_max_genes': [766.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1213.2, 36130.25], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                             0
                           {'min_max_genes': [798.75, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1176.375, 28050.25], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                          0
                           {'min_max_genes': [822.975, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1282.925, 23156.550000000007], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}               0
                           {'min_max_genes': [923.4000000000001, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1489.7, 37456.77499999999], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}        0
Space Flight | 37 Weeks    {'min_max_genes': [200, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [300, 14724.999999999998], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                     5747
                           {'min_max_genes': [628.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [895.0, 19711.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                            4922
                           {'min_max_genes': [766.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1213.2, 36130.25], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                          4050
                           {'min_max_genes': [719.475, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1128.9, 33910.62499999997], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}               3864
                           {'min_max_genes': [316.3, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [376.3, 11766.900000000009], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                 1321
                           {'min_max_genes': [201.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [300, 10018.199999999983], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                      0
                           {'min_max_genes': [321.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [414.0, 11122.175000000005], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                    0
                           {'min_max_genes': [326.1, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [422.1, 13468.399999999998], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                    0
                           {'min_max_genes': [331.925, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [452.77500000000003, 13453.3], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                0
                           {'min_max_genes': [481.425, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [681.7, 27907.149999999994], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                  0
                           {'min_max_genes': [507.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [696.45, 23662.899999999972], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                   0
                           {'min_max_genes': [666.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [942.0, 21190.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                               0
                           {'min_max_genes': [700.2, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1087.2, 35338.0], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                              0
                           {'min_max_genes': [703.0, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1006.1500000000001, 23784.40000000001], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}        0
                           {'min_max_genes': [798.75, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1176.375, 28050.25], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                          0
                           {'min_max_genes': [809.825, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1300.3, 32231.825000000015], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}                 0
                           {'min_max_genes': [822.975, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1282.925, 23156.550000000007], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}               0
                           {'min_max_genes': [923.4000000000001, None], 'min_max_cells': [20, None], 'max_mt': 10, 'min_max_counts': [1489.7, 37456.77499999999], 'target_sum': 10000.0, 'zero_center': True, 'max_value': 10, 'n_top_genes': 2000, 'doublet_detection': 'drop'}        0
Name: count, dtype: int64 


kws_cluster_individual 

 kws_cluster_individual
{'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50}      93932
{'resolution': 0.5, 'min_dist': 1.5, 'n_comps': 50}       5747
{'resolution': 0.075, 'min_dist': 1.5, 'n_comps': 50}     3595
Name: count, dtype: int64 


kws_cluster_individual 

 Group                      kws_cluster_individual                               
Ground Control | 20 Weeks  {'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50}      31600
                           {'resolution': 0.5, 'min_dist': 1.5, 'n_comps': 50}          0
                           {'resolution': 0.075, 'min_dist': 1.5, 'n_comps': 50}        0
Ground Control | 37 Weeks  {'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50}      31767
                           {'resolution': 0.075, 'min_dist': 1.5, 'n_comps': 50}     3595
                           {'resolution': 0.5, 'min_dist': 1.5, 'n_comps': 50}          0
Space Flight | 20 Weeks    {'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50}      16408
                           {'resolution': 0.5, 'min_dist': 1.5, 'n_comps': 50}          0
                           {'resolution': 0.075, 'min_dist': 1.5, 'n_comps': 50}        0
Space Flight | 37 Weeks    {'resolution': 0.2, 'min_dist': 1.5, 'n_comps': 50}      14157
                           {'resolution': 0.5, 'min_dist': 1.5, 'n_comps': 50}       5747
                           {'resolution': 0.075, 'min_dist': 1.5, 'n_comps': 50}        0
Name: count, dtype: int64 


Age_Start 

 Age_Start
29 Weeks    55266
12 Weeks    48008
Name: count, dtype: int64 


Age_Start 

 Group                      Age_Start
Ground Control | 20 Weeks  12 Weeks     31600
                           29 Weeks         0
Ground Control | 37 Weeks  29 Weeks     35362
                           12 Weeks         0
Space Flight | 20 Weeks    12 Weeks     16408
                           29 Weeks         0
Space Flight | 37 Weeks    29 Weeks     19904
                           12 Weeks         0
Name: count, dtype: int64 


Age_End 

 Age_End
37 Weeks    55266
20 Weeks    48008
Name: count, dtype: int64 


Age_End 

 Group                      Age_End 
Ground Control | 20 Weeks  20 Weeks    31600
                           37 Weeks        0
Ground Control | 37 Weeks  37 Weeks    35362
                           20 Weeks        0
Space Flight | 20 Weeks    20 Weeks    16408
                           37 Weeks        0
Space Flight | 37 Weeks    37 Weeks    19904
                           20 Weeks        0
Name: count, dtype: int64 


Condition 

 Condition
Ground Control    66962
Space Flight      36312
Name: count, dtype: int64 


Condition 

 Group                      Condition     
Ground Control | 20 Weeks  Ground Control    31600
                           Space Flight          0
Ground Control | 37 Weeks  Ground Control    35362
                           Space Flight          0
Space Flight | 20 Weeks    Space Flight      16408
                           Ground Control        0
Space Flight | 37 Weeks    Space Flight      19904
                           Ground Control        0
Name: count, dtype: int64 


Spaceflight 

 Spaceflight
0    66962
1    36312
Name: count, dtype: int64 


Spaceflight 

 Group                      Spaceflight
Ground Control | 20 Weeks  0              31600
                           1                  0
Ground Control | 37 Weeks  0              35362
                           1                  0
Space Flight | 20 Weeks    1              16408
                           0                  0
Space Flight | 37 Weeks    1              19904
                           0                  0
Name: count, dtype: int64 


Aged 

 Aged
1    55266
0    48008
Name: count, dtype: int64 


Aged 

 Group                      Aged
Ground Control | 20 Weeks  0       31600
                           1           0
Ground Control | 37 Weeks  1       35362
                           0           0
Space Flight | 20 Weeks    0       16408
                           1           0
Space Flight | 37 Weeks    1       19904
                           0           0
Name: count, dtype: int64 


       Parameter Value[Sample Storage Temperature]  Parameter Value[duration]           Time  doublet_score  leiden_min_dist  leiden_n_neighbors  leiden_resolution  log1p_n_genes_by_counts  log1p_total_counts  log1p_total_counts_hb  log1p_total_counts_mt  log1p_total_counts_ribo  \
count                                     103274.0                   103274.0  103274.000000  103274.000000     1.032740e+05            103274.0       1.032740e+05            103274.000000       103274.000000          103274.000000          103274.000000            103274.000000   
mean                                         -80.0                       53.0     973.638302       0.041344     1.800000e+00                15.0       7.500000e-03                 7.417736            7.881183               0.260397               2.382938                 2.902018   
std                                            0.0                        0.0     164.049552       0.044008     4.440914e-16                 0.0       5.204196e-18                 0.778077            0.360944               0.395849               0.573577                 0.851048   
min                                          -80.0                       53.0     650.000000       0.000939     1.800000e+00                15.0       7.500000e-03                 5.407172            6.692673               0.000000               0.000000                 0.000000   
25%                                          -80.0                       53.0     870.000000       0.012658     1.800000e+00                15.0       7.500000e-03                 6.786999            7.619952               0.000000               2.033528                 2.411256   
50%                                          -80.0                       53.0    1019.000000       0.026517     1.800000e+00                15.0       7.500000e-03                 7.514800            7.977367               0.000000               2.417125                 2.970734   
75%                                          -80.0                       53.0    1107.000000       0.051769     1.800000e+00                15.0       7.500000e-03                 8.114025            8.198943               0.560137               2.784262                 3.545701   
max                                          -80.0                       53.0    1210.000000       0.427957     1.800000e+00                15.0       7.500000e-03                 8.866300            8.475933               2.865808               3.876799                 5.215870   

       majority_voting_probabilities  n_cells_original_sample       n_counts        n_genes  n_genes_by_counts  pct_counts_hb  pct_counts_mt  pct_counts_ribo  resolution_leiden_subcluster   total_counts  total_counts_hb  total_counts_mt  total_counts_ribo  
count                   8.174000e+04            103274.000000  103274.000000  103274.000000      103274.000000  103274.000000  103274.000000    103274.000000                  1.032740e+05  103274.000000    103274.000000    103274.000000      103274.000000  
mean                    8.004442e-01              8868.877617    6141.850098    2285.132850        2174.142524       0.014995       0.485460         0.829614                  5.000000e-03    2808.240723         0.422456        11.600281          23.477568  
std                     3.244514e-01              5555.444146    6050.134766    1536.856773        1450.048991       0.033161       0.373723         0.614553                  8.673659e-19     893.974487         0.739523         6.798219          17.732740  
min                     4.892193e-13              1493.000000     300.000000     228.000000         222.000000       0.000000       0.000000         0.000000                  5.000000e-03     805.475098         0.000000         0.000000           0.000000  
25%                     7.655978e-01              4863.000000    1469.000000     928.000000         885.250000       0.000000       0.217165         0.393203                  5.000000e-03    2037.464783         0.000000         6.640997          10.147949  
50%                     9.809476e-01              6503.000000    3866.000000    1918.000000        1834.000000       0.000000       0.389005         0.673524                  5.000000e-03    2913.247192         0.000000        10.213576          18.506222  
75%                     9.984942e-01             10779.000000    9198.000000    3499.000000        3340.000000       0.020098       0.639635         1.106981                  5.000000e-03    3636.102173         0.750913        15.187874          33.663980  
max                     1.000000e+00             20000.000000   37385.000000    7625.000000        7088.000000       0.962084       3.545085         8.041131                  5.000000e-03    4796.899414        16.563232        47.269436         183.171951  
                          Parameter Value[Sample Storage Temperature]                                          Parameter Value[duration]                                              Time                                                                  doublet_score                                \
                                                                count  mean  std   min   25%   50%   75%   max                     count  mean  std   min   25%   50%   75%   max    count         mean         std     min     25%     50%     75%     max         count      mean       std       min   
Group                                                                                                                                                                                                                                                                                                     
Ground Control | 20 Weeks                                     31600.0 -80.0  0.0 -80.0 -80.0 -80.0 -80.0 -80.0                   31600.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0  31600.0  1106.037310   77.118373   961.0  1082.0  1107.0  1149.0  1210.0       31600.0  0.026022  0.024241  0.000939   
Ground Control | 37 Weeks                                     35362.0 -80.0  0.0 -80.0 -80.0 -80.0 -80.0 -80.0                   35362.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0  35362.0  1052.704655   39.889900  1019.0  1019.0  1019.0  1085.0  1139.0       35362.0  0.065153  0.058371  0.001629   
Space Flight | 20 Weeks                                       16408.0 -80.0  0.0 -80.0 -80.0 -80.0 -80.0 -80.0                   16408.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0  16408.0   728.490005   89.844140   660.0   661.0   707.0   707.0   885.0       16408.0  0.027771  0.023537  0.001713   
Space Flight | 37 Weeks                                       19904.0 -80.0  0.0 -80.0 -80.0 -80.0 -80.0 -80.0                   19904.0  53.0  0.0  53.0  53.0  53.0  53.0  53.0  19904.0   825.057124  100.790958   650.0   704.0   869.0   870.0   915.0       19904.0  0.034561  0.032071  0.001516   

                                                                  leiden_min_dist                                             leiden_n_neighbors                                          leiden_resolution          ... pct_counts_mt           pct_counts_ribo                                     \
                                25%       50%       75%       max           count mean           std  min  25%  50%  75%  max              count  mean  std   min   25%   50%   75%   max             count    mean  ...           75%       max           count      mean       std  min       25%   
Group                                                                                                                                                                                                                ...                                                                              
Ground Control | 20 Weeks  0.009311  0.020458  0.033229  0.200935         31600.0  1.8  4.440962e-16  1.8  1.8  1.8  1.8  1.8            31600.0  15.0  0.0  15.0  15.0  15.0  15.0  15.0           31600.0  0.0075  ...      0.448150  2.817153         31600.0  0.551147  0.303721  0.0  0.349949   
Ground Control | 37 Weeks  0.019517  0.046690  0.098458  0.427957         35362.0  1.8  4.440955e-16  1.8  1.8  1.8  1.8  1.8            35362.0  15.0  0.0  15.0  15.0  15.0  15.0  15.0           35362.0  0.0075  ...      0.673306  3.545085         35362.0  0.575305  0.424046  0.0  0.280994   
Space Flight | 20 Weeks    0.009819  0.022242  0.037975  0.200935         16408.0  1.8  4.441027e-16  1.8  1.8  1.8  1.8  1.8            16408.0  15.0  0.0  15.0  15.0  15.0  15.0  15.0           16408.0  0.0075  ...      0.677820  3.291983         16408.0  1.219632  0.526935  0.0  0.871887   
Space Flight | 37 Weeks    0.012640  0.026172  0.045226  0.238307         19904.0  1.8  4.441004e-16  1.8  1.8  1.8  1.8  1.8            19904.0  15.0  0.0  15.0  15.0  15.0  15.0  15.0           19904.0  0.0075  ...      0.881699  3.462019         19904.0  1.402012  0.757490  0.0  0.865775   

                                                        resolution_leiden_subcluster                                                total_counts                                                                                           total_counts_hb                                               \
                                50%       75%       max                        count   mean  std    min    25%    50%    75%    max        count         mean         std          min          25%          50%          75%          max           count      mean       std  min  25%  50%       75%   
Group                                                                                                                                                                                                                                                                                                     
Ground Control | 20 Weeks  0.483076  0.682583  5.470688                      31600.0  0.005  0.0  0.005  0.005  0.005  0.005  0.005      31600.0  2953.787842  798.679749  1018.616394  2250.032227  3126.676025  3657.309753  4613.192871         31600.0  0.425118  0.705483  0.0  0.0  0.0  0.773112   
Ground Control | 37 Weeks  0.463607  0.800191  6.749294                      35362.0  0.005  0.0  0.005  0.005  0.005  0.005  0.005      35362.0  2466.579346  903.588867   805.475098  1692.396820  2325.938477  3256.262817  4643.960449         35362.0  0.347006  0.732018  0.0  0.0  0.0  0.000000   
Space Flight | 20 Weeks    1.140313  1.465173  7.849742                      16408.0  0.005  0.0  0.005  0.005  0.005  0.005  0.005      16408.0  3084.272949  886.075806  1048.266235  2296.486633  3326.058594  3859.608948  4713.582520         16408.0  0.491993  0.748583  0.0  0.0  0.0  0.847184   
Space Flight | 37 Weeks    1.233290  1.743376  8.041131                      19904.0  0.005  0.0  0.005  0.005  0.005  0.005  0.005      19904.0  2956.621094  842.863586   841.438477  2152.055481  3264.747681  3681.248230  4796.899414         19904.0  0.494954  0.783714  0.0  0.0  0.0  0.851087   

                                     total_counts_mt                                                                           total_counts_ribo                                                                          
                                 max           count       mean       std      min        25%        50%        75%        max             count       mean        std  min        25%        50%        75%         max  
Group                                                                                                                                                                                                                     
Ground Control | 20 Weeks  16.016462         31600.0   8.755315  5.311935  0.00000   4.922410   7.545821  11.342984  38.111645           31600.0  16.063892   9.233896  0.0  10.094914  14.208097  19.950861  122.755669  
Ground Control | 37 Weeks  14.150034         35362.0   9.977168  5.348376  0.00000   6.191418   9.340921  12.932923  38.388371           35362.0  15.267353  13.528916  0.0   5.782949  10.543948  21.744246  153.015076  
Space Flight | 20 Weeks    14.123777         16408.0  14.411705  6.304240  1.30298   9.522820  13.322799  18.381306  41.757008           16408.0  37.125362  17.822294  0.0  24.397658  35.151552  47.261961  183.171951  
Space Flight | 37 Weeks    16.563232         19904.0  16.683048  7.844715  0.00000  10.419192  15.606552  22.051781  47.269436           19904.0  38.583508  17.900896  0.0  25.322685  36.105711  48.775124  166.185165  

[4 rows x 200 columns]


*** Cell Composition (%) ***

annotation_scanvi_collapsed   Astrocyte  Endothelial  Microglial  Neuron   OPC  Oligodendrocyte
sample                                                                                         
RRRM2_BRN_GC_ISS-T_YNG_GY4         7.23         2.76        3.47   63.04  7.31            16.18
RRRM2_BRN_GC_ISS-T_YNG_GY9         9.13         1.32        3.37   65.51  3.44            17.24
RRRM2_BRN_GC_ISS-T_OLD_GO18        8.63         0.84        3.42   70.23  3.01            13.87
RRRM2_BRN_FLT_ISS-T_OLD_FO20       6.89         1.30        3.64   58.80  3.51            25.86
RRRM2_BRN_GC_ISS-T_OLD_GO19        6.53         0.77        3.41   67.28  3.46            18.56
RRRM2_BRN_GC_ISS-T_OLD_GO13        9.65         1.78        3.12   54.24  3.64            27.57
RRRM2_BRN_FLT_ISS-T_YNG_FY8        8.24         0.57        5.61   57.76  4.38            23.43
RRRM2_BRN_FLT_ISS-T_YNG_FY7        6.62         0.11        4.36   56.85  3.49            28.56
RRRM2_BRN_FLT_ISS-T_OLD_FO19       5.31         1.20        3.74   73.99  2.44            13.33
RRRM2_BRN_GC_ISS-T_YNG_GY7         9.69         1.14        3.25   58.27  4.03            23.63
RRRM2_BRN_FLT_ISS-T_OLD_FO14       7.89         0.03        4.06   60.90  3.83            23.29
RRRM2_BRN_GC_ISS-T_YNG_GY1         8.63         1.03        3.87   61.96  3.70            20.81
RRRM2_BRN_FLT_ISS-T_YNG_FY2        7.64         0.03        4.42   59.73  3.81            24.37
RRRM2_BRN_FLT_ISS-T_OLD_FO17       2.65         0.00        1.97   80.32  4.84            10.22
RRRM2_BRN_GC_ISS-T_OLD_GO16        3.64         0.03        1.22   86.82  1.46             6.83
RRRM2_BRN_FLT_ISS-T_OLD_FO16       7.28         0.02        4.25   66.20  3.21            19.04
RRRM2_BRN_GC_ISS-T_YNG_GY2         7.58         1.34        3.08   59.28  3.79            24.93
RRRM2_BRN_FLT_ISS-T_YNG_FY5        7.28         0.51        3.83   67.17  3.76            17.45


                               Original Cell N  N Cells  Percent_Filtered
sample                                                                  
RRRM2_BRN_GC_ISS-T_OLD_GO13              3880     3595              7.35
RRRM2_BRN_GC_ISS-T_YNG_GY1               3968     3672              7.46
RRRM2_BRN_GC_ISS-T_OLD_GO16             20000    18386              8.07
RRRM2_BRN_GC_ISS-T_YNG_GY7               5776     5265              8.85
RRRM2_BRN_FLT_ISS-T_OLD_FO14             4260     3864              9.30
RRRM2_BRN_GC_ISS-T_YNG_GY9               6044     5465              9.58
RRRM2_BRN_FLT_ISS-T_YNG_FY2              4125     3730              9.58
RRRM2_BRN_FLT_ISS-T_YNG_FY8              5658     5095              9.95
RRRM2_BRN_GC_ISS-T_OLD_GO18              6503     5842             10.16
RRRM2_BRN_GC_ISS-T_YNG_GY2              10779     9651             10.46
RRRM2_BRN_GC_ISS-T_OLD_GO19              8476     7539             11.05
RRRM2_BRN_FLT_ISS-T_OLD_FO17             1493     1321             11.52
RRRM2_BRN_GC_ISS-T_YNG_GY4               8542     7547             11.65
RRRM2_BRN_FLT_ISS-T_OLD_FO20             5641     4922             12.75
RRRM2_BRN_FLT_ISS-T_YNG_FY7              4238     3669             13.43
RRRM2_BRN_FLT_ISS-T_OLD_FO16             4863     4050             16.72
RRRM2_BRN_FLT_ISS-T_YNG_FY5              4714     3914             16.97
RRRM2_BRN_FLT_ISS-T_OLD_FO19             7265     5747             20.89

Get Marker Gene Sets¶

From Google Drive, except senmayo derived from file downloaded from https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/SAUL_SEN_MAYO.html then created using:

from pybiomart import Server

senmayo = pd.read_csv("resources/SAUL_SEN_MAYO.v2025.1.Hs.tsv",
                      sep="\t", header=0)
senmayo = senmayo[senmayo.STANDARD_NAME == "GENE_SYMBOLS"]
senmayo = pd.Series({"Senmayo": senmayo.iloc[0, 1].split(
    ",")}, name="symbol").rename_axis("Gene_Set").explode().str.strip(
        ).replace("", np.nan).dropna().to_frame()
server = Server(host="http://www.ensembl.org")
mart = server.marts["ENSEMBL_MART_ENSEMBL"] # Access the Ensembl mart
human_dataset = mart.datasets["hsapiens_gene_ensembl"]
orthologs = human_dataset.query(attributes=[
    "external_gene_name", "mmusculus_homolog_associated_gene_name"])
orthologs = orthologs.dropna().set_index(orthologs.columns[0])
orthologs = orthologs.loc[orthologs.index.intersection(
    senmayo.symbol.to_list())].iloc[:, 0]
print(f"{orthologs.shape[0]} orthologs found out of"
      f" {len(senmayo.symbol.unique())} senmayo genes")
senmayo = senmayo.assign(symbol=senmayo.replace({"symbol": dict(zip(
    orthologs.index, orthologs.values))}))
senmayo.to_csv("gene_sets/senmayo.csv")

(Also could use scflow.tl.convert_gene_species(senmayo.symbol.to_list()))

Certain gene sets created from Google Drive ADBR AWG > Projects > White Matter > Gene Sets files (with the suffix = "_adjusted") were modified for consistency, e.g.,

pd.read_csv("gene_sets/_iron_genes_gmt_out.csv", index_col=[
    0, 1]).rename_axis(["row_id", "pathway"]).stack().to_frame(
        "symbol").reset_index(-1, drop=True).reset_index().to_csv(
            "gene_sets/_iron_genes_gmt_out_adjusted.csv")

A Priori¶

In [3]:
mks = [pd.read_csv(os.path.join("gene_sets", i)).dropna(
    how="all", axis=1).assign(Source_File=i) for i in os.listdir("gene_sets")]
mks = [x.assign(Gene_Set=x["Source_File"].iloc[0].split("_2025")[0]) if (
    "pathway" in x) else x for x in mks]
mks = pd.concat(mks).drop("Unnamed: 0", axis=1).drop("row_id", axis=1)
mks = mks[mks.symbol.isin(self.rna.var_names)]
mks = mks[["Gene_Set", "symbol"]].set_index("Gene_Set").groupby(
    "Gene_Set").apply(lambda x: x["symbol"].to_list())
marker_genes_dict = dict(mks)
marker_gene_sets = mks.copy()
print(marker_gene_sets)
Gene_Set
GOBP_CELLULAR_RESPONSE_TO_IRON_ION                                                                                                                                                                                                                          [B2m, Bmp6, Gpld1, Ireb2, Tfrc, Trf]
GOBP_CENTRAL_NERVOUS_SYSTEM_MYELIN_FORMATION                                                                                                                                                                                                      [Abca2, Ckap5, Cntn1, Ercc2, Mag, Mios, Tenm4]
GOBP_INTRACELLULAR_IRON_ION_HOMEOSTASIS                                                                                                                                                      [Abcb7, Aco1, Atp13a2, Atp6ap1, Atp6v0a2, Atp6v0d1, Atp6v1a, Atp6v1g1, B2m, Bmp6, Bmyc, Bola2, C...
GOBP_IRON_COORDINATION_ENTITY_TRANSPORT                                                                                                                                                                                                        [Abcb7, Abcc5, Flvcr1, Pgrmc2, Slc22a17, Slc48a1]
GOBP_IRON_ION_IMPORT_ACROSS_PLASMA_MEMBRANE                                                                                                                                                                                                                                       [Iscu, Steap2]
GOBP_IRON_ION_TRANSMEMBRANE_TRANSPORT                                                                                                                                                           [Abcb7, Abcc5, Atp7a, Hif1a, Iscu, Nos1, Slc11a2, Slc25a28, Slc25a37, Slc39a14, Slc48a1, Steap2]
GOBP_IRON_ION_TRANSPORT                                                                                                                                                                      [Abcb7, Abcc5, Arhgap1, Atp7a, B2m, Cltc, Dnm2, Flvcr1, Fth1, Heph, Hif1a, Iscu, Lmtk2, Mmgt1, M...
GOBP_MULTICELLULAR_ORGANISMAL_LEVEL_IRON_ION_HOMEOSTASIS                                                                                                                                          [Ank1, B2m, Bmp6, Btbd9, Eif2ak1, Epas1, Fbxl5, Fech, Htt, Ireb2, Neo1, Picalm, Slc11a2, Sod2]
GOBP_MYELIN_ASSEMBLY                                                                                                                                                                         [Abca2, Cd9, Ckap5, Cntn1, Cntnap1, Dicer1, Epb41l3, Ercc2, Fig4, Gnpat, Gpc1, Ilk, Mag, Mios, M...
GOBP_MYELIN_MAINTENANCE                                                                                                                                                                      [Abcd1, Abcd2, Akt1, Akt2, Clu, Degs1, Epb41l3, Fa2h, Myrf, Ndrg1, Pals1, Plec, Pten, Sh3tc2, Sod1]
GOBP_NEGATIVE_REGULATION_OF_IRON_ION_TRANSMEMBRANE_TRANSPORT                                                                                                                                                                                                                 [Atp7a, Iscu, Nos1]
GOBP_NEGATIVE_REGULATION_OF_IRON_ION_TRANSPORT                                                                                                                                                                                                                               [Atp7a, Iscu, Nos1]
GOBP_REGULATION_OF_IRON_ION_TRANSMEMBRANE_TRANSPORT                                                                                                                                                                                                                          [Atp7a, Iscu, Nos1]
GOBP_REGULATION_OF_IRON_ION_TRANSPORT                                                                                                                                                                                                                              [Atp7a, B2m, Iscu, Nos1, Trf]
GOBP_REGULATION_OF_MYELINATION                                                                                                                                                               [Akt1, Cdh2, Ctnnb1, Cyfip1, Dag1, Dicer1, Dlg1, Eif2ak3, Fig4, Hes5, Hgf, Hnrnpk, Igf1, Jam2, L...
GOBP_RESPONSE_TO_IRON_ION                                                                                                                                                                                                           [Abat, Aco1, B2m, Bcl2, Bmp6, Gpld1, Ireb2, Snca, Tfrc, Trf]
GOBP_SEQUESTERING_OF_IRON_ION                                                                                                                                                                                                                                                       [Fth1, Ftl1]
GOBP_SPHINGOMYELIN_BIOSYNTHETIC_PROCESS                                                                                                                                                                                       [Abca8a, Abca8b, Ormdl3, Osbp, Samd8, Sgms1, Sptlc1, Sptlc2, Vapa]
GOBP_SPHINGOMYELIN_CATABOLIC_PROCESS                                                                                                                                                                                                              [Prkcd, Smpd1, Smpd3, Smpd4, Smpdl3a, Smpdl3b]
GOBP_SPHINGOMYELIN_METABOLIC_PROCESS                                                                                                                                                         [Abca2, Abca8a, Abca8b, Ormdl3, Osbp, Prkcd, Samd8, Sgms1, Smpd1, Smpd3, Smpd4, Smpdl3a, Smpdl3b...
GOMF_FERRIC_IRON_BINDING                                                                                                                                                                                                                                                       [Fth1, Ftl1, Trf]
GOMF_FERROUS_IRON_BINDING                                                                                                                                                                    [Alkbh1, Alkbh3, Cdo1, Dnajc24, Egln1, Egln2, Fth1, Ftl1, Fto, Heph, Hif1an, Iscu, Nt5e, Phyh, P...
GOMF_FERROUS_IRON_TRANSMEMBRANE_TRANSPORTER_ACTIVITY                                                                                                                                                                                              [Mmgt1, Slc11a2, Slc25a28, Slc25a37, Slc39a14]
GOMF_IRON_ION_BINDING                                                                                                                                                                        [Abce1, Aco2, Ado, Agmo, Alkbh1, Alkbh3, Alkbh8, Calr, Cdo1, Ciapin1, Cisd1, Cygb, Cyp11a1, Cyp2...
GOMF_IRON_ION_TRANSMEMBRANE_TRANSPORTER_ACTIVITY                                                                                                                                                                                            [Mmgt1, Slc11a2, Slc25a28, Slc25a37, Slc39a14, Tfrc]
GOMF_OXIDOREDUCTASE_ACTIVITY_ACTING_ON_PAIRED_DONORS_WITH_INCORPORATION_OR_REDUCTION_OF_MOLECULAR_OXYGEN_REDUCED_IRON_SULFUR_PROTEIN_AS_ONE_DONOR_AND_INCORPORATION_OF_ONE_ATOM_OF_OXYGEN                                                                           [Ahr, Cyp11a1, Cyp2u1, Fdx1]
GOMF_SPHINGOMYELIN_PHOSPHODIESTERASE_ACTIVITY                                                                                                                                                                                                            [Smpd1, Smpd3, Smpd4, Smpdl3a, Smpdl3b]
GOMF_STRUCTURAL_CONSTITUENT_OF_MYELIN_SHEATH                                                                                                                                                                                                           [Gpm6b, Mal, Mal2, Mbp, Mobp, Pllp, Plp1]
REACTOME_IRON_UPTAKE_AND_TRANSPORT                                                                                                                                                           [Aco1, Atp6ap1, Atp6v0a1, Atp6v0a2, Atp6v0a4, Atp6v0b, Atp6v0c, Atp6v0d1, Atp6v0e, Atp6v0e2, Atp...
REACTOME_MITOCHONDRIAL_IRON_SULFUR_CLUSTER_BIOGENESIS                                                                                                                                                                                 [Fdx1, Fdxr, Glrx5, Hscb, Isca1, Isca2, Iscu, Lyrm4, Nfs1]
Senmayo                                                                                                                                                                                      [Acvr1b, Angpt1, Bex3, Bmp6, Cd9, Csf1, Ctnnb1, Ctsb, Egf, Egfr, Ets2, Fgf1, Hgf, Hmgb1, Igf1, I...
WP_IRON_HOMEOSTASIS                                                                                                                                                                                                                                                     [Fth1, Ftl1, Ireb2, Trf]
dtype: object

Clusters in Data¶

In [4]:
self.find_markers(col_celltype=col_celltype)
df_celltype_markers = self.get_markers_df(
    n_genes=50, col_celltype=col_celltype,
    log2fc_threshold=1, p_threshold=1e-10)
df_celltype_markers.groupby(col_celltype).apply(lambda x: x.head(3))
No description has been provided for this image
Out[4]:
scores logfoldchanges pvals pvals_adj
annotation_scanvi_collapsed annotation_scanvi_collapsed names
Astrocyte Astrocyte Bcl2 48.966312 2.244818 0.000000e+00 0.000000e+00
Abhd3 47.107872 3.003248 0.000000e+00 0.000000e+00
Ugp2 47.243469 2.251395 0.000000e+00 0.000000e+00
Endothelial Endothelial Zbtb20 71.523643 3.209239 0.000000e+00 0.000000e+00
Cped1 37.842743 7.205899 3.891507e-186 6.621035e-185
9530026P05Rik 34.913925 5.121674 7.849119e-168 1.249353e-166
Microglial Microglial Tgfbr1 151.537048 7.483766 0.000000e+00 0.000000e+00
Hexb 150.142044 5.966863 0.000000e+00 0.000000e+00
Plxdc2 145.446838 4.734621 0.000000e+00 0.000000e+00
Neuron Neuron Pde7a 56.121979 1.154942 0.000000e+00 0.000000e+00
Chic1 55.948746 1.314887 0.000000e+00 0.000000e+00
Pkig 55.969212 1.236063 0.000000e+00 0.000000e+00
OPC OPC Lhfpl3 161.057190 5.147624 0.000000e+00 0.000000e+00
Tnr 131.139984 4.126481 0.000000e+00 0.000000e+00
Sox6 118.223061 5.241720 0.000000e+00 0.000000e+00
Oligodendrocyte Oligodendrocyte Map4k5 52.164612 1.264680 0.000000e+00 0.000000e+00
Dleu2 54.534840 1.288954 0.000000e+00 0.000000e+00
E130308A19Rik 54.438168 1.582712 0.000000e+00 0.000000e+00

Regress Out?¶

In [5]:
# if vars_regress_out is not None:
#     self.rna.X = self.rna.layers["log1p"].copy()
#     sc.pp.regress_out(self.rna, vars_regress_out)
#     self.rna.layers["log1p"] = self.rna.X.copy()
#     pkg.pp.scale(self.rna, zero_center=True, max_value=10)
#     self.rna.layers["scaled"] = self.rna.X.copy()
#     self.rna.X = self.rna.layers["log1p"].copy()

Score Senescence¶

Run Scoring¶

If you want just to find the senescence-related genes, run:

tissue = "Brain"  # or whatever you want here
celltype = None  # or whatever you want here
genes_senepy, hubs, figs = find_senescence_genes(
    self.rna, species=species, tissue=tissue, celltype=celltype,
    overlap_threshold=0, literature_sources=None,
    sengpt_sources=True, plot=True, col_celltype=col_celltype
)  # find tissue- and/or cell type-specific genes

To see available hubs:

hubs = senepy.load_hubs(species=species)
hubs.metadata.set_index(["tissue", "cell"]).sort_index()

Other examples of arguments you could use:

# tissue = ["Brain", "Myeloid"]
# tissue = None

# celltype = "GABA interneuron"  # only human I think
# celltype = ["microglia", "t cell", "monocyte"]
# celltype = "microglia"
# celltype = "microglial cell"`

Senepy¶

In [6]:
%%time

tissue = "Brain"
celltype = None  # use all cell types

if "senepy" in sen_metrics:
    self.rna.X = self.rna.layers["log1p"].copy()
    self.rna, genes_senepy, figs = run_senepy(
        self.rna, species=species, tissue=tissue, celltype=celltype,
        overlap_threshold=0, literature_sources=None,
        sengpt_sources=True, col_celltype=col_celltype,
        col_senscore="score_senepy", identifiers=[col_celltype],
        use_translator=True, plot=True, figsize=(20, 20),
        swap_axes=False, standard_scale="group", plot_layer="log1p"
    )  # find tissue- and/or cell type-specific genes
    self.rna.obs.loc[
        :, "score_senepy_original_scale"] = self.rna.obs.score_senepy
    self.rna.obs.loc[:, "score_senepy"] = np.log(
        self.rna.obs.score_senepy)  # log-transform senescence score
    self.rna.obs[["score_senepy"]]
CPU times: user 2 μs, sys: 1e+03 ns, total: 3 μs
Wall time: 5.72 μs

Senmayo¶

In [7]:
if "senmayo" in sen_metrics:
    sc.tl.score_genes(self.rna, marker_gene_sets.loc["Senmayo"],
                      ctrl_as_ref=True, ctrl_size=50, gene_pool=None,
                      n_bins=25, score_name="score_senmayo", random_state=0,
                      copy=False, layer="log1p", use_raw=False)

Label SnCs¶

Define Snc Threshold & Label Cells¶

Based on percentile threshold derived from control group

In [8]:
# Determine Threshold
perc_s, perc = str(100 - percentile) + "%", 1 - (percentile / 100)
p_h = 3
perc_s_h, perc_h = str(100 - p_h) + "%", 1 - (p_h / 100)
print("Percentile for Threshold:", perc_s)
for u in sen_metrics:
    self.rna.obs = self.rna.obs.join(self.rna.obs[self.rna.obs[
        col_batch] == keys[col_batch]["key_control"]].groupby(
            col_celltype).apply(lambda x: x[f"score_{u}"].describe(
                percentiles=[perc])[perc_s], include_groups=False).to_frame(
                    f"Senescence_Threshold_{u}"), on=col_celltype).loc[
                        self.rna.obs.index]
    self.rna.obs = self.rna.obs.join(self.rna.obs[self.rna.obs[
        col_batch] == keys[col_batch]["key_control"]].groupby(
            col_celltype).apply(lambda x: x[f"score_{u}"].describe(
                percentiles=[perc_h])[perc_s_h],
                                include_groups=False).to_frame(
                                    f"Senescence_Threshold_{u}_{p_h}"),
                                on=col_celltype).loc[self.rna.obs.index]

# Binary CLassification
for x in sen_metrics:
    self.rna.obs.loc[:, f"Senescent_Cell_{x}"] = (self.rna.obs[
        f"score_{x}"] >= self.rna.obs[f"Senescence_Threshold_{x}"])
    self.rna.obs.loc[:, f"Senescent_Cell_{x}_{p_h}"] = (self.rna.obs[
        f"score_{x}"] >= self.rna.obs[f"Senescence_Threshold_{x}_{p_h}"])

# String Labels (for Plotting/Categorical Analysis)
for x in sen_metrics:
    self.rna.obs.loc[:, f"Senescent_Cell_Label_{x}"] = self.rna.obs[
        f"Senescent_Cell_{x}"].astype(bool).astype(str).replace({
            "True": "Senescent", "False": "Non-Senescent"})
    self.rna.obs.loc[:, f"Senescent_Cell_Label_hierarchy_{x}"] = self.rna.obs[
        f"Senescent_Cell_{x}"].astype(bool).astype(str).replace({
            "True": "Senescent", "False": "Non-Senescent"})
    self.rna.obs.loc[:, f"Senescent_Cell_Label_{x}_{p_h}"] = self.rna.obs[
        f"Senescent_Cell_{x}_{p_h}"].astype(bool).astype(str).replace({
            "True": "Senescent", "False": "Non-Senescent"})
    self.rna.obs.loc[:, f"Senescent_Cell_Label_by_Type_{x}"] = self.rna.obs[
        f"Senescent_Cell_Label_{x}"].replace({
            "Senescent": "SnC ", "Non-Senescent": ""}) + self.rna.obs[
                col_celltype].astype(str)
    self.rna.obs.loc[:, f"SnC_hierarchy_{x}"] = self.rna.obs[
        f"Senescent_Cell_Label_{x}"].replace({
            "Senescent": "SnC ", "Non-Senescent": ""}) + self.rna.obs[
                col_celltype + "_hierarchy"].astype(str)

# Descriptives
for x in sen_metrics:
    print(x, round(self.rna.obs[[
        f"Senescent_Cell_Label_{x}", col_celltype]].value_counts(
            normalize=True).sort_index() * 100, 1).unstack(0))

# Choose Metrics for Main Analysis
for x in ["Senescent_Cell_Label", "Senescent_Cell", "SnC_hierarchy",
            "Senescence_Threshold", "Senescent_Cell_Label_by_Type"]:
    self.rna.obs.loc[:, x] = self.rna.obs[f"{x}_{use_metric}"]
self.rna.obs.loc[:, "senscore"] = self.rna.obs[f"score_{use_metric}"]
self.rna.obs.loc[
    :, f"Senescent_Cell_Label_by_Type_{use_metric}_{p_h}"] = self.rna.obs[
        f"Senescent_Cell_Label_{use_metric}_{p_h}"].replace({
            "Non-Senescent": "", "Senescent": "SnC "}).astype(
                str) + self.rna.obs[
                    col_celltype].astype(str)  # lower threshold SnC by type
genes = marker_gene_sets.loc["Senmayo"] if (
    use_metric == "senmayo") else genes_senepy  # main senescence gene list

# Avoid Nesting Duplication Issues
self.rna.obs.loc[:, "SnC_hierarchy"] = self.rna.obs[
    "SnC_hierarchy"].replace({
        "Neuron": "Neurons", "SnC Neuron": "SnC Neurons"})
Percentile for Threshold: 99%
senmayo Senescent_Cell_Label_senmayo  Non-Senescent  Senescent
annotation_scanvi_collapsed                           
Astrocyte                               6.8        0.1
Endothelial                             0.8        0.0
Microglial                              3.2        0.1
Neuron                                 65.9        1.5
OPC                                     3.4        0.0
Oligodendrocyte                        17.9        0.2

Label Batch/Cell-Specific Senescence Percentiles¶

In [9]:
# for x in ["Senescence_Label", "Senescence_CellType"]:
#     if x in self.rna.obs:
#         self.rna.obs = self.rna.obs.drop(x, axis=1)

# # %ile Thresholds (Overall)
# thresh = self.rna.obs["score_senepy"].describe(
#     percentiles=[0.90, 0.95, 0.99])
# thres_ct =  self.rna.obs[["score_senepy", col_celltype]].groupby(
#     col_celltype).describe(percentiles=[0.90, 0.95, 0.99])["score_senepy"]

# sen = self.rna.obs["score_senepy"].apply(
#     lambda x: "Top 1%" if x >= float(thresh.loc["99%"]) else "Top 5%" if (
#         x >= float(thresh.loc["95%"])) else "Top 10%" if x >= float(
#             thresh.loc["90%"]) else "Bottom 90%").to_frame(
#                 "Senescence_Label").loc[self.rna.obs.index]
# self.rna.obs = self.rna.obs.join(sen).loc[self.rna.obs.index]

# # %ile Thresholds (by Cell Type)
# sct = self.rna.obs.groupby(
#     col_celltype).apply(lambda g: g["score_senepy"].apply(
#         lambda x: f"Top 1% {g.name}" if x >= float(thres_ct.loc[g.name][
#             "99%"]) else f"Top 5% {g.name}" if (x >= float(thres_ct.loc[
#                 g.name]["95%"])) else f"Top 10% {g.name}" if x >= float(
#                     thres_ct.loc[g.name]["90%"]) else g.name),
#                         include_groups=False)

# sct = sct.to_frame("Senescence_CellType").reset_index(0, drop=True)
# sct = sct.loc[self.rna.obs.index]
# self.rna.obs = self.rna.obs.join(sct).loc[self.rna.obs.index]

# for x in ["Senescence_Label", "Senescence_CellType"]:
#     self.rna.obs = self.rna.obs.assign(**{
#         x: self.rna.obs[x].astype("category")})

# high_sen_cts = [i for i in self.rna.obs["Senescence_CellType"].unique(
#     ) if " 1% " in i]

Descriptives of SnCs¶

In [10]:
print("Percent Senescent: \n\n", round(self.rna.obs.groupby([
    col_celltype, col_batch]).apply(lambda x: x["Senescent_Cell"].astype(
        int).value_counts(normalize=True), include_groups=False) * 100,
    2).unstack(col_celltype))
sns.catplot(self.rna.obs, y="Senescent_Cell", x=col_celltype,
            hue=col_batch, kind="bar", height=10)
Percent Senescent: 

 annotation_scanvi_collapsed               Astrocyte  Endothelial  Microglial  Neuron    OPC  Oligodendrocyte
Group                     Senescent_Cell                                                                    
Ground Control | 20 Weeks 0                   98.96        98.82       98.96   98.99  98.97            99.00
                          1                    1.04         1.18        1.04    1.01   1.03             1.00
Ground Control | 37 Weeks 0                   98.41        96.59       97.73   97.23  98.92            99.01
                          1                    1.59         3.41        2.27    2.77   1.08             0.99
Space Flight | 20 Weeks   0                   98.22       100.00       97.90   98.18  98.59            98.33
                          1                    1.78          NaN        2.10    1.82   1.41             1.67
Space Flight | 37 Weeks   0                   96.87        97.78       97.60   96.63  97.71            98.34
                          1                    3.13         2.22        2.40    3.37   2.29             1.66
Out[10]:
<seaborn.axisgrid.FacetGrid at 0x70d63fa56510>
No description has been provided for this image

SnC DEGs¶

Overall¶

In [11]:
p_threshold = 1e-10
lfc_threshold = 1
self.find_markers(col_celltype="Senescent_Cell_Label_by_Type")
df_snc_markers = {}
df_snc_markers["All"] = self.get_markers_df(
    n_genes=50, col_celltype="Senescent_Cell_Label_by_Type",
    log2fc_threshold=1, p_threshold=1e-10)
# print(df_snc_markers["All"].loc[pd.unique([
#     i[0] for i in df_snc_markers["All"].index.values if (
#         "SnC" in i[0])])].groupby("Senescent_Cell_Label_by_Type").apply(
#             lambda x: x.head(3)))
for x in self.rna.obs[col_celltype].unique():
    df_snc_markers[x] = self.find_markers(
        col_celltype="Senescent_Cell_Label_by_Type",
        reference=x, groups=[x, f"SnC {x}"], rankby_abs=True,
        inplace=False).reset_index(0, drop=True).assign(**{
            col_celltype: f"SnC {x}"}).reset_index().set_index([
                col_celltype, "names"])
df_snc_markers = pd.concat(df_snc_markers, names=["Comparison"])
df_snc_markers = df_snc_markers.rename_axis([
    "Comparison", col_celltype, "names"]).rename({
        "logfoldchanges": "log_fc"}, axis=1).assign(
            log_fc_abs=df_snc_markers["logfoldchanges"].abs())
df_snc_markers_top = df_snc_markers[df_snc_markers.pvals_adj < p_threshold]
df_snc_markers_top = df_snc_markers_top[
    df_snc_markers.log_fc_abs >= lfc_threshold]
df_snc_markers_top = df_snc_markers_top.groupby([
    "Comparison", col_celltype]).apply(
        lambda x: x.assign(scores_abs=x.scores.abs()).sort_values(
            "scores_abs", ascending=False).head(20),
        include_groups=False).reset_index([0, 1], drop=True)
... storing 'Senescent_Cell_Label_senmayo' as categorical
... storing 'Senescent_Cell_Label_hierarchy_senmayo' as categorical
... storing 'Senescent_Cell_Label_senmayo_3' as categorical
... storing 'Senescent_Cell_Label_by_Type_senmayo' as categorical
... storing 'SnC_hierarchy_senmayo' as categorical
... storing 'Senescent_Cell_Label' as categorical
... storing 'SnC_hierarchy' as categorical
... storing 'Senescent_Cell_Label_by_Type' as categorical
... storing 'Senescent_Cell_Label_by_Type_senmayo_3' as categorical
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

By Group¶

In [ ]:
res_rank_genes, p_threshold = {}, 1e-10
for x in self.rna.obs[col_batch].unique():
    res_rank_genes[x] = {}
    for c in self.rna.obs[self.rna.obs[col_batch] == x][
            col_celltype].unique():
        s_iter = (self.rna.obs[col_batch] == x) & (self.rna.obs[
            "Senescent_Cell_Label_by_Type"].isin([c, f"SnC {c}"]))
        tmp = sc.tl.rank_genes_groups(
            self.rna[s_iter], "Senescent_Cell_Label_by_Type", rankby_abs=True,
            layer="log1p", groups=[c, f"SnC {c}"], reference=c, copy=True)
        res_rank_genes[x][c] = sc.get.rank_genes_groups_df(
            tmp, f"SnC {c}", pval_cutoff=p_threshold)
    tmp = sc.tl.rank_genes_groups(
            self.rna[self.rna.obs[col_batch] == x],
            "Senescent_Cell_Label", rankby_abs=True,
            layer="log1p", reference="Non-Senescent", copy=True)
    res_rank_genes[x]["Overall"] = sc.get.rank_genes_groups_df(
            tmp, f"Senescent", pval_cutoff=p_threshold)
    res_rank_genes[x] = pd.concat(res_rank_genes[x], names=[col_celltype])
res_rank_genes = pd.concat(res_rank_genes, names=[col_batch])
res_rank_genes = res_rank_genes.assign(
    logfoldchanges_abs=res_rank_genes.logfoldchanges.abs())
res_rank_genes_top = res_rank_genes.reset_index().groupby([
    col_batch, col_celltype]).apply(
        lambda x: x.sort_values("logfoldchanges_abs").iloc[:20],
        include_groups=False).reset_index(2, drop=True).set_index(
            "names", append=True).rename_axis([
                col_batch, col_celltype, "variable"])
res_rank_genes_top

Plot¶

Comparison¶

In [ ]:
scores = self.rna.obs[[col_batch] + [
    f"score_{x}" for x in sen_metrics]].set_index(
        col_batch, append=True).reset_index()
sns.pairplot(scores, diag_kind="kde", diag_kws=dict(
    cut=0, fill=True, common_norm=True),
             hue=col_batch, palette=palette[col_batch])
Out[ ]:
<seaborn.axisgrid.PairGrid at 0x7c539e317cb0>
No description has been provided for this image

Scores¶

In [13]:
# UMAP with Senescence Scores
bnds = self.rna.obs["senscore"].describe(percentiles=[0.75, 0.99])
_ = self.plot(kind="umap", color=["senscore", col_celltype], umap=dict(
    palette=None, color_map="Reds", vmin=bnds["75%"], vmax=bnds["99%"]))

# Violin Plot of Senescence Scores
_ = self.plot(kind="violin", genes=["senscore"], common_norm=True,
              col_celltype=col_celltype, rotation=90)
_ = self.plot(kind="violin", genes=["senscore"], common_norm=True,
              by_group=col_celltype, col_wrap=1,
              col_celltype=col_batch, rotation=90)

# KDEs
fig_sen_kde = {}
for x in [col_age, col_condition, col_batch]:
    fig_sen_kde[x] = sns.displot(self.rna.obs, hue=x, x="senscore",
                                 palette=palette[x], kind="kde",
                                 cut=0, common_norm=True, fill=True)

# Overall (All Cell Types)
fig_sen_overall = sns.catplot(self.rna.obs, x=col_condition,
                              hue=col_age, y="senscore",
                              palette=palette[col_age],
                              kind="violin")
fig_sen_overall_2 = sns.catplot(self.rna.obs, x=col_age, hue=col_condition,
                                palette=palette[col_condition],
                                y="senscore", kind="violin")

# By Cell Type
fig_sen_rc = sns.catplot(self.rna.obs, col=col_celltype, y="senscore",
                         palette=palette[col_condition],
                         hue=col_condition, x=col_age, kind="violin",
                         height=10, aspect=2, col_wrap=3)
fig_sen = sns.catplot(self.rna.obs, x=col_celltype, y="senscore",
                      palette=palette[col_batch],
                      hue=col_batch, kind="box", height=10, aspect=2)
for a in fig_sen.axes.flatten():
    a.tick_params(axis="x", labelrotation=90)
fig_sen_2 = sns.catplot(self.rna.obs, x=col_celltype, y="senscore",
                        col=col_age, hue=col_condition,
                        palette=palette[col_condition],
                        kind="box", height=10, aspect=2)
for a in fig_sen_2.axes.flatten():
    a.tick_params(axis="x", labelrotation=90)
fig_sen_3 = sns.catplot(self.rna.obs, x=col_celltype, y="senscore",
                        col=col_condition, hue=col_age,
                        palette=palette[col_age],
                        kind="box", height=10, aspect=2)
for a in fig_sen_3.axes.flatten():
    a.tick_params(axis="x", labelrotation=90)
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

Burden¶

Group by sample and cell type and get percentage of senescent cells

In [14]:
grps = [col_sample, col_celltype, col_age, col_condition, col_batch]
dff = self.rna.obs[grps + ["Senescent_Cell"]].groupby(grps).apply(
    lambda x: x["Senescent_Cell"].mean(), include_groups=False
    ).to_frame("Senescent_Cell_Burden") * 100
# kws_plot = dict(kind="violin", split=False, , common_norm=True)
kws_plot = dict(kind="box", errorbar=("ci", 95))

sns.catplot(y="Senescent_Cell_Burden", x=col_condition, **kws_plot,
            palette=palette[col_condition],
            hue=col_condition, data=dff, height=3, aspect=1.5)
sns.catplot(y="Senescent_Cell_Burden", x=col_condition, **kws_plot,
            col=col_celltype, col_wrap=4,
            palette=palette[col_age],
            hue=col_age, data=dff, height=3, aspect=1.5)
sns.catplot(y="Senescent_Cell_Burden", hue=col_condition, **kws_plot,
            col=col_celltype, col_wrap=4,
            palette=palette[col_condition],
            x=col_age, data=dff, height=3, aspect=1.5)
sns.catplot(y="Senescent_Cell_Burden", x=col_celltype, **kws_plot,
            palette=palette[col_batch],
            hue=col_batch, data=dff, height=8, aspect=1.5)
for x in [col_condition, col_age, [col_condition, col_age]]:
    print("\n\n", round(dff["Senescent_Cell_Burden"].groupby(x).describe()[[
        "min", "25%", "50%", "75%", "max"]], 1))
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)

                 min  25%  50%  75%   max
Condition                               
Ground Control  0.0  0.4  1.0  2.0   6.2
Space Flight    0.0  0.9  1.8  2.3  11.1


           min  25%  50%  75%   max
Age_End                           
20 Weeks  0.0  0.5  1.2  2.0   5.0
37 Weeks  0.0  0.5  1.6  3.2  11.1


                          min  25%  50%  75%   max
Condition      Age_End                           
Ground Control 20 Weeks  0.0  0.4  0.8  1.7   5.0
               37 Weeks  0.0  0.4  1.5  3.2   6.2
Space Flight   20 Weeks  0.0  0.8  1.6  2.1   3.3
               37 Weeks  0.0  0.9  1.9  2.9  11.1
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/seaborn/categorical.py:700: PendingDeprecationWarning: vert: bool will be deprecated in a future version. Use orientation: {'vertical', 'horizontal'} instead.
  artists = ax.bxp(**boxplot_kws)
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

Analyze¶

Regressions & ANOVAs & MEMs¶

In [15]:
r_dff = polars.DataFrame(dff.reset_index())  # pymer-compatible aggregated df
r_rna = polars.DataFrame(self.rna.obs.rename({
    col_celltype: "CT_"}, axis=1).copy())  # pymer-compatible cell-level df
lvls = ["key_control", "key_treatment"]
factors = {col_condition: [keys[col_condition][i] for i in lvls],
           col_age: [keys[col_age][i] for i in lvls]}

Scores¶

Cell Type Random Effects¶
In [ ]:
# # Age + Condition
# model_ca_mlm = lmer(f"senscore ~ {col_condition} + {col_age} +"
#                     f"(1 | {col_sample})", data=r_rna)  # set up model
# model_ca_mlm.set_factors(factors)
# model_ca_mlm.set_transforms({"senscore": "zscore"})
# model_ca_mlm.anova(summary=True).show()

# # Age * Condition
# model_ca_mlm_i = lmer(
#     f"senscore ~ {col_condition} * {col_age} + "
#     f"(1 | {col_sample})", data=r_rna)  # set up model
# model_ca_mlm_i.set_factors(factors)
# model_ca_mlm_i.set_transforms({"senscore": "zscore"})
# model_ca_mlm_i.anova(summary=True).show()

# # Age * Condition (Condition as Random Effect)
# model_ca_mlm_ii = lmer(
#     f"senscore ~ {col_condition} * {col_age} + "
#     f"(1 | {col_sample}) + (1 + {col_condition} | CT_)",
#     data=r_rna)  # set up model
# model_ca_mlm_ii.set_factors(factors)
# model_ca_mlm_ii.set_transforms({"senscore": "zscore"})
# model_ca_mlm_ii.anova(summary=True).show()

# Age * Condition (Age and Condition as Random Effect)
model_ca_mlm_iii = lmer(
    f"senscore ~ {col_condition} * {col_age} + (1 | {col_sample})"
    f" + (1 + {col_condition} + {col_age} | CT_)",
    data=r_rna)  # set up model
model_ca_mlm_iii.set_factors(factors)
model_ca_mlm_iii.set_transforms({"senscore": "zscore"})
model_ca_mlm_iii.anova(summary=True).show()

# Model Comparison
# compare(model_ca_mlm, model_ca_mlm_i, model_ca_mlm_i,
#         model_ca_mlm_ii, model_ca_mlm_iii).show()

# GLM Version of Results
# model_ca_mlm.summary().show()
# model_ca_mlm_i.summary().show()
# model_ca_mlm_ii.summary().show()
model_ca_mlm_iii.summary().show()
R messages: 
Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
To enable adjustments, add the argument 'lmerTest.limit = 103274' (or larger)
[or, globally, 'set emm_options(lmerTest.limit = 103274)' or larger];
but be warned that this may result in large computation time and memory use.

R messages: 
Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
To enable adjustments, add the argument 'lmerTest.limit = 103274' (or larger)
[or, globally, 'set emm_options(lmerTest.limit = 103274)' or larger];
but be warned that this may result in large computation time and memory use.

ANOVA (Type III tests)
model term df1 df2 F_ratio Chisq p_value
Condition 1.000 inf 5.960 5.960 0.01463 *
Age_End 1.000 inf 2.150 2.150 0.1426
Condition:Age_End 1.000 inf 0.349 0.349 0.5549
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
Formula: lmer(senscore~Condition*Age_End+(1|sample)+(1+Condition+Age_End|CT_))
Number of observations: 103274
Confidence intervals: parametric
---------------------
Log-likelihood: -137950
AIC: 275925 | BIC: 276040
Residual error: 0.919
Random Effects: Estimate SE CI-low CI-high T-stat DF p
sample-sd (Intercept) 0.159
CT_-sd (Intercept) 0.636
CT_-sd ConditionSpace Flight 0.148
CT_-sd Age_End37 Weeks 0.256
CT_-cor (Intercept) 0.042
CT_-cor (Intercept) 0.564
CT_-cor ConditionSpace Flight −0.793
Residual-sd Observation 0.919
Fixed Effects:
(Intercept) 0.330 0.269 −0.336 0.995 1.224 5.769 0.2687
ConditionSpace Flight 0.283 0.123 0.023 0.542 2.290 17.931 0.03436 *
Age_End37 Weeks 0.235 0.150 −0.087 0.557 1.565 14.053 0.1399
ConditionSpace Flight:Age_End37 Weeks −0.089 0.152 −0.415 0.236 −0.590 13.918 0.5644
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1

Cell Type as Moderator¶

In [32]:
# Age + Condition * Cell Type
model_cac_mlm_i2 = lmer(
    f"senscore ~  Aged + Spaceflight * CT_ + "
    f"(1 | {col_sample})", data=r_rna)  # set up model
model_cac_mlm_i2.set_transforms({"senscore": "zscore"})
model_cac_mlm_i2.anova(summary=True).show()

# Age * Condition * Cell Type
model_cac_mlm_i2b = lmer(
    f"senscore ~  Aged * Spaceflight + Spaceflight * CT_ + "
    f"(1 | {col_sample})", data=r_rna)  # set up model
model_cac_mlm_i2b.set_transforms({"senscore": "zscore"})
model_cac_mlm_i2b.anova(summary=True).show()

# Age * Condition * Cell Type
model_cac_mlm_i3 = lmer(
    f"senscore ~  Aged * Spaceflight * CT_ + "
    f"(1 | {col_sample})", data=r_rna)  # set up model
model_cac_mlm_i3.set_transforms({"senscore": "zscore"})
model_cac_mlm_i3.anova(summary=True).show()

# GLM Version of Results
model_cac_mlm_i2.summary().show()
model_cac_mlm_i2b.summary().show()
model_cac_mlm_i3.summary().show()

# Model Comparison
compare(model_cac_mlm_i2, model_cac_mlm_i2b, model_cac_mlm_i3).show()
ANOVA (Type III tests)
model term df1 df2 F_ratio Chisq p_value
Aged 1.000 inf 5.640 5.640 0.01755 *
Spaceflight 1.000 inf 11.454 11.454 <.001 ***
annotation_scanvi_collapsed 5.000 inf 2,746.320 13,731.600 ***
Spaceflight:annotation_scanvi_collapsed 5.000 inf 29.008 145.040 <.001 ***
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
ANOVA (Type III tests)
model term df1 df2 F_ratio Chisq p_value
Aged 1.000 inf 5.415 5.415 0.01996 *
Spaceflight 1.000 inf 11.021 11.021 <.001 ***
annotation_scanvi_collapsed 5.000 inf 2,746.334 13,731.670 ***
Aged:Spaceflight 1.000 inf 0.408 0.408 0.5228
Spaceflight:annotation_scanvi_collapsed 5.000 inf 28.996 144.980 <.001 ***
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
ANOVA (Type III tests)
model term df1 df2 F_ratio Chisq p_value
Aged 1.000 inf 5.981 5.981 0.01446 *
Spaceflight 1.000 inf 9.339 9.339 0.002243 **
annotation_scanvi_collapsed 5.000 inf 2,669.438 13,347.190 ***
Aged:Spaceflight 1.000 inf 0.130 0.130 0.7185
Aged:annotation_scanvi_collapsed 5.000 inf 37.304 186.520 <.001 ***
Spaceflight:annotation_scanvi_collapsed 5.000 inf 34.950 174.750 <.001 ***
Aged:Spaceflight:annotation_scanvi_collapsed 5.000 inf 18.125 90.625 <.001 ***
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
Formula: lmer(senscore~Aged+Spaceflight*annotation_scanvi_collapsed+(1|sample))
Number of observations: 103274
Confidence intervals: parametric
---------------------
Log-likelihood: -138067
AIC: 276164 | BIC: 276307
Residual error: 0.921
Random Effects: Estimate SE CI-low CI-high T-stat DF p
sample-sd (Intercept) 0.157
Residual-sd Observation 0.921
Fixed Effects:
(Intercept) 0.439 0.064 0.304 0.574 6.898 16.211 <.001 ***
Aged 0.178 0.075 0.018 0.338 2.375 14.933 0.03139 *
Spaceflight 0.309 0.078 0.145 0.473 3.954 17.619 <.001 ***
annotation_scanvi_collapsedEndothelial 0.886 0.038 0.812 0.960 23.426 103,248.906 <.001 ***
annotation_scanvi_collapsedMicroglial 0.450 0.025 0.400 0.499 17.750 103,246.539 <.001 ***
annotation_scanvi_collapsedNeuron −0.675 0.014 −0.703 −0.647 −47.191 103,253.259 ***
annotation_scanvi_collapsedOPC −0.292 0.024 −0.338 −0.245 −12.372 103,249.458 <.001 ***
annotation_scanvi_collapsedOligodendrocyte −0.921 0.016 −0.952 −0.889 −56.980 103,248.648 ***
Spaceflight:annotation_scanvi_collapsedEndothelial −0.105 0.079 −0.260 0.050 −1.326 103,251.597 0.185
Spaceflight:annotation_scanvi_collapsedMicroglial 0.054 0.039 −0.023 0.131 1.382 103,246.538 0.1669
Spaceflight:annotation_scanvi_collapsedNeuron −0.177 0.024 −0.224 −0.130 −7.342 103,255.169 <.001 ***
Spaceflight:annotation_scanvi_collapsedOPC 0.078 0.039 0.000 0.155 1.971 103,249.550 0.04874 *
Spaceflight:annotation_scanvi_collapsedOligodendrocyte −0.154 0.027 −0.206 −0.102 −5.786 103,248.885 <.001 ***
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
Formula: lmer(senscore~Aged*Spaceflight+Spaceflight*annotation_scanvi_collapsed+(1|sample))
Number of observations: 103274
Confidence intervals: parametric
---------------------
Log-likelihood: -138068
AIC: 276168 | BIC: 276320
Residual error: 0.921
Random Effects: Estimate SE CI-low CI-high T-stat DF p
sample-sd (Intercept) 0.161
Residual-sd Observation 0.921
Fixed Effects:
(Intercept) 0.417 0.073 0.261 0.573 5.700 14.781 <.001 ***
Aged 0.227 0.108 −0.005 0.459 2.099 13.868 0.05458 .
Spaceflight 0.358 0.110 0.123 0.593 3.243 15.072 0.00543 **
annotation_scanvi_collapsedEndothelial 0.886 0.038 0.812 0.960 23.427 103,248.573 <.001 ***
annotation_scanvi_collapsedMicroglial 0.450 0.025 0.400 0.499 17.750 103,246.502 <.001 ***
annotation_scanvi_collapsedNeuron −0.675 0.014 −0.703 −0.647 −47.192 103,252.374 ***
annotation_scanvi_collapsedOPC −0.292 0.024 −0.338 −0.245 −12.372 103,249.147 <.001 ***
annotation_scanvi_collapsedOligodendrocyte −0.921 0.016 −0.952 −0.889 −56.979 103,248.519 ***
Aged:Spaceflight −0.098 0.153 −0.426 0.230 −0.639 13.920 0.5331
Spaceflight:annotation_scanvi_collapsedEndothelial −0.105 0.079 −0.260 0.050 −1.325 103,251.272 0.1851
Spaceflight:annotation_scanvi_collapsedMicroglial 0.054 0.039 −0.023 0.131 1.382 103,246.493 0.167
Spaceflight:annotation_scanvi_collapsedNeuron −0.177 0.024 −0.224 −0.130 −7.340 103,253.333 <.001 ***
Spaceflight:annotation_scanvi_collapsedOPC 0.078 0.039 0.000 0.155 1.971 103,249.395 0.04876 *
Spaceflight:annotation_scanvi_collapsedOligodendrocyte −0.154 0.027 −0.206 −0.102 −5.787 103,248.734 <.001 ***
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
Formula: lmer(senscore~Aged*Spaceflight*annotation_scanvi_collapsed+(1|sample))
Number of observations: 103274
Confidence intervals: parametric
---------------------
Log-likelihood: -137917
AIC: 275887 | BIC: 276135
Residual error: 0.919
Random Effects: Estimate SE CI-low CI-high T-stat DF p
sample-sd (Intercept) 0.160
Residual-sd Observation 0.919
Fixed Effects:
(Intercept) 0.501 0.074 0.345 0.658 6.807 15.524 <.001 ***
Aged 0.037 0.111 −0.198 0.271 0.332 15.559 0.7445
Spaceflight 0.183 0.112 −0.054 0.419 1.636 16.243 0.1211
annotation_scanvi_collapsedEndothelial 0.651 0.045 0.564 0.739 14.573 103,239.106 <.001 ***
annotation_scanvi_collapsedMicroglial 0.385 0.034 0.320 0.451 11.492 103,236.384 <.001 ***
annotation_scanvi_collapsedNeuron −0.794 0.019 −0.831 −0.756 −41.346 103,237.111 ***
annotation_scanvi_collapsedOPC −0.248 0.030 −0.307 −0.189 −8.212 103,240.534 <.001 ***
annotation_scanvi_collapsedOligodendrocyte −0.957 0.021 −0.999 −0.915 −44.915 103,237.945 ***
Aged:Spaceflight 0.270 0.158 −0.064 0.605 1.709 16.359 0.1064
Aged:annotation_scanvi_collapsedEndothelial 0.768 0.085 0.602 0.935 9.035 103,239.001 <.001 ***
Aged:annotation_scanvi_collapsedMicroglial 0.146 0.051 0.046 0.246 2.859 103,236.545 0.004246 **
Aged:annotation_scanvi_collapsedNeuron 0.257 0.029 0.200 0.313 8.925 103,242.983 <.001 ***
Aged:annotation_scanvi_collapsedOPC −0.158 0.048 −0.253 −0.063 −3.270 103,238.157 0.001078 **
Aged:annotation_scanvi_collapsedOligodendrocyte 0.073 0.033 0.009 0.137 2.235 103,238.959 0.02542 *
Spaceflight:annotation_scanvi_collapsedEndothelial 0.037 0.135 −0.229 0.302 0.272 103,238.411 0.7855
Spaceflight:annotation_scanvi_collapsedMicroglial 0.239 0.054 0.133 0.345 4.419 103,236.398 <.001 ***
Spaceflight:annotation_scanvi_collapsedNeuron 0.016 0.034 −0.051 0.082 0.463 103,237.130 0.6436
Spaceflight:annotation_scanvi_collapsedOPC 0.167 0.054 0.061 0.273 3.098 103,237.478 0.001951 **
Spaceflight:annotation_scanvi_collapsedOligodendrocyte 0.035 0.037 −0.037 0.107 0.946 103,239.194 0.3443
Aged:Spaceflight:annotation_scanvi_collapsedEndothelial −0.690 0.175 −1.032 −0.347 −3.946 103,239.781 <.001 ***
Aged:Spaceflight:annotation_scanvi_collapsedMicroglial −0.383 0.079 −0.537 −0.229 −4.868 103,236.505 <.001 ***
Aged:Spaceflight:annotation_scanvi_collapsedNeuron −0.406 0.048 −0.500 −0.311 −8.407 103,243.233 <.001 ***
Aged:Spaceflight:annotation_scanvi_collapsedOPC −0.105 0.079 −0.260 0.051 −1.319 103,239.000 0.1871
Aged:Spaceflight:annotation_scanvi_collapsedOligodendrocyte −0.375 0.053 −0.480 −0.270 −7.022 103,238.919 <.001 ***
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
Analysis of Deviance Table
Model 1: lmer(senscore~Aged+Spaceflightannotation_scanvi_collapsed+(1|sample))
Model 2: lmer(senscore~Aged
Spaceflight+Spaceflightannotation_scanvi_collapsed+(1|sample))
Model 3: lmer(senscore~Aged
Spaceflight*annotation_scanvi_collapsed+(1|sample))
AIC BIC logLik npar -2*log(L) Chisq Df Pr(>Chisq)
1.00 276164.7 276307.9 −138067.4 15.00 276.06K
2.00 276168.3 276321 −138068.1 16.00 276.06K 0.52 1.00 0.47
3.00 275887.1 276135.3 −137917.5 26.00 275.72K 345.22 10.00 <.001 ***
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1

Binary Snc/Not¶

Multilevel Logistic Regression

Cell Type Random Effects¶

In [38]:
glmmod = {}
# for x in ["1", f"1 + {col_condition}", f"1 + {col_condition} + {col_age}"]:
#     fff = str(f"Senescent_Cell ~ {col_age} * {col_condition}"
#               f" + (1 | {col_sample}) + ({x} | CT_)")
for x in ["1", f"1 + Spaceflight", f"1 + Spaceflight + Aged"]:
    sep = "|" if x == "1" else "||"
    fff = str(f"Senescent_Cell ~ Aged * Spaceflight"
              f" + (1 | {col_sample}) + ({x} {sep} CT_)")
    glmmod[x] = glmer(fff, data=r_rna, family="binomial")
    # glmmod[x].set_factors(factors)
    glmmod[x].fit(exponentiate=True, ncpus=ncpus)  # estimates => odds
    # print(glmmod[x].emmeans(col_condition))
    # print(glmmod[x].emmeans(col_age))
    glmmod[x].summary().show()
    # print(glmmod[x].ranef["CT_"])
compare(*[glmmod[x] for x in glmmod])

# Plot
# grid = sns.FacetGrid(self.rna.obs, col=col_age, hue=col_condition)
# grid.map(sns.countplot, "Senescent_Cell", order=[False, True])
# grid.add_legend()
# grid.set_xlabels("")
# grid.set_xticklabels(["Not SnC", "Snc"])
# sns.despine()
# fig = plt.figure(figsize=(10, 2))
# g_s = fig.add_gridspec(1, 2, width_ratios=[1, 3])
# left, right = fig.add_subplot(g_s[0]), fig.add_subplot(g_s[1])
# left = sns.kdeplot(x="resid", data=glmmod.data, ax=left)
# left.set(xlabel="Residuals", title="Error Distribution")
# right.stem(glmmod.data["cooksd"], basefmt=" ", label="Cook's Distance")
# right.set(xlabel="Row Number", ylabel="Cook's Distance",
#           title="Influential Observations",
#           xticks=range(glmmod.data.height))
# sns.despine()
Formula: glmer(Senescent_Cell~Aged*Spaceflight+(1|sample)+(1|CT_))
Family: binomial (link: default)
Number of observations: 103274
Confidence intervals: parametric
---------------------
Log-likelihood: -9686
AIC: 19384 | BIC: 19441
Residual error: 1.0
Random Effects: Estimate CI-low CI-high SE Z-stat df p
sample-sd (Intercept) 0.567
CT_-sd (Intercept) 0.159
Fixed Effects:
(Intercept) 0.008 0.004 0.015 0.003 −14.011 inf <.001 ***
Aged 2.015 0.688 5.895 1.104 1.279 inf 0.201
Spaceflight 2.211 0.818 5.976 1.122 1.564 inf 0.1177
Aged:Spaceflight 0.839 0.179 3.925 0.660 −0.223 inf 0.8232
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
R messages: 
boundary (singular) fit: see help('isSingular')

R messages: 
boundary (singular) fit: see help('isSingular')

R messages: 
boundary (singular) fit: see help('isSingular')

Formula: glmer(Senescent_Cell~Aged*Spaceflight+(1|sample)+(1+Spaceflight||CT_))
Family: binomial (link: default)
Number of observations: 103274
Confidence intervals: parametric
---------------------
Log-likelihood: -9686
AIC: 19386 | BIC: 19453
Residual error: 1.0
Random Effects: Estimate CI-low CI-high SE Z-stat df p
sample-sd (Intercept) 0.567
CT_-sd (Intercept) 0.159
CT_.1-sd Spaceflight 0.000
Fixed Effects:
(Intercept) 0.008 0.005 0.012 0.002 −19.452 inf <.001 ***
Aged 2.015 1.085 3.742 0.636 2.218 inf 0.02658 *
Spaceflight 2.211 1.116 4.381 0.771 2.275 inf 0.02291 *
Aged:Spaceflight 0.839 0.371 1.898 0.349 −0.422 inf 0.6728
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
R messages: 
boundary (singular) fit: see help('isSingular')

R messages: 
boundary (singular) fit: see help('isSingular')

R messages: 
boundary (singular) fit: see help('isSingular')

Formula: glmer(Senescent_Cell~Aged*Spaceflight+(1|sample)+(1+Spaceflight+Aged||CT_))
Family: binomial (link: default)
Number of observations: 103274
Confidence intervals: parametric
---------------------
Log-likelihood: -9675
AIC: 19367 | BIC: 19443
Residual error: 1.0
Random Effects: Estimate CI-low CI-high SE Z-stat df p
sample-sd (Intercept) 0.565
CT_-sd (Intercept) 0.000
CT_.1-sd Spaceflight 0.000
CT_.2-sd Aged 0.275
Fixed Effects:
(Intercept) 0.008 0.005 0.013 0.002 −20.199 inf <.001 ***
Aged 1.787 0.869 3.675 0.657 1.578 inf 0.1145
Spaceflight 2.196 1.117 4.319 0.758 2.281 inf 0.02256 *
Aged:Spaceflight 0.848 0.343 2.099 0.392 −0.357 inf 0.7215
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
Out[38]:
Analysis of Deviance Table
Model 1: glmer(Senescent_Cell~AgedSpaceflight+(1|sample)+(1|CT_))
Model 2: glmer(Senescent_Cell~Aged
Spaceflight+(1|sample)+(1+Spaceflight||CT_))
Model 3: glmer(Senescent_Cell~Aged*Spaceflight+(1|sample)+(1+Spaceflight+Aged||CT_))
AIC BIC logLik npar -2*log(L) Chisq Df Pr(>Chisq)
1.00 19384.2 19441.5 −9686.1 6.00 19.37K
2.00 19386.2 19453 −9686.1 7.00 19.37K 1.00 1.0
3.00 19367.6 19443.9 −9675.8 8.00 19.35K 20.62 1.00 <.001 ***
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1

Cell Type as Moderator¶

In [39]:
# 2-Way Interaction
fff = str(f"Senescent_Cell ~ Aged + Spaceflight * CT_ + "
          "(1 | sample)")
glmmod_ct2 = glmer(fff, data=r_rna, family="binomial")
glmmod_ct2.fit(exponentiate=True, ncpus=ncpus)  # estimates => odds
glmmod_ct2.summary().show()

# 2 2-Way Interactions
fff = str(f"Senescent_Cell ~  Aged * Spaceflight + Spaceflight * CT_"
          f" + (1 | {col_sample})")
glmmod_ct2b = glmer(fff, data=r_rna, family="binomial")
glmmod_ct2b.fit(exponentiate=True, ncpus=ncpus)  # estimates => odds
glmmod_ct2b.anova(summary=True).show()
glmmod_ct2b.summary().show()

# 3-Way Interaction
fff = str(f"Senescent_Cell ~  Aged * Spaceflight * CT_"
          f" + (1 | {col_sample})")
model_allix = glmer(fff, data=r_rna, family="binomial")
model_allix.fit(exponentiate=True, ncpus=ncpus)  # estimates => odds
model_allix.anova(summary=True).show()
model_allix.summary().show()
res_allix_fixed = pd.DataFrame(model_allix.result_fit[[
    "term", "estimate", "p_value"]], columns=[
        "Term", "OR", "P"]).set_index("Term")
res_allix_fixed.loc[:, "Log-Odds"] = np.log(
    res_allix_fixed.OR.astype(float))
res_allix_fixed.loc[:, "Significance"] = res_allix_fixed.P.apply(
    lambda x: "***" if x < 0.001 else "**" if x < 0.01 else "*" if (
        x < 0.05) else "")
print(res_allix_fixed)

# Model Comparison
compare(glmmod_ct2, glmmod_ct2b, model_allix)
Formula: glmer(Senescent_Cell~Aged+Spaceflight*CT_+(1|sample))
Family: binomial (link: default)
Number of observations: 103274
Confidence intervals: parametric
---------------------
Log-likelihood: -9678
AIC: 19385 | BIC: 19518
Residual error: 1.0
Random Effects: Estimate CI-low CI-high SE Z-stat df p
sample-sd (Intercept) 0.564
Fixed Effects:
(Intercept) 0.008 0.005 0.012 0.002 −19.911 inf <.001 ***
Aged 1.844 1.107 3.070 0.480 2.352 inf 0.01867 *
Spaceflight 2.545 1.372 4.719 0.802 2.964 inf 0.003037 **
CT_Endothelial 1.474 0.802 2.708 0.457 1.250 inf 0.2113
CT_Microglial 1.245 0.811 1.911 0.272 1.004 inf 0.3155
CT_Neuron 1.219 0.953 1.558 0.153 1.579 inf 0.1142
CT_OPC 0.773 0.497 1.202 0.174 −1.143 inf 0.253
CT_Oligodendrocyte 0.820 0.610 1.104 0.124 −1.308 inf 0.1907
Spaceflight:CT_Endothelial 0.359 0.091 1.416 0.251 −1.463 inf 0.1434
Spaceflight:CT_Microglial 0.706 0.384 1.299 0.220 −1.118 inf 0.2637
Spaceflight:CT_Neuron 0.781 0.548 1.114 0.141 −1.364 inf 0.1725
Spaceflight:CT_OPC 0.878 0.466 1.655 0.284 −0.402 inf 0.6879
Spaceflight:CT_Oligodendrocyte 0.813 0.535 1.235 0.174 −0.971 inf 0.3316
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
ANOVA (Type III tests)
model term df1 df2 F_ratio Chisq p_value
Aged 1.000 inf 5.378 5.378 0.02039 *
Spaceflight 1.000 inf 4.301 4.301 0.03808 *
CT_ 5.000 inf 6.731 33.655 <.001 ***
Aged:Spaceflight 1.000 inf 0.110 0.110 0.7399
Spaceflight:CT_ 5.000 inf 0.862 4.310 0.5054
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
Formula: glmer(Senescent_Cell~Aged*Spaceflight+Spaceflight*CT_+(1|sample))
Family: binomial (link: default)
Number of observations: 103274
Confidence intervals: parametric
---------------------
Log-likelihood: -9678
AIC: 19387 | BIC: 19530
Residual error: 1.0
Random Effects: Estimate CI-low CI-high SE Z-stat df p
sample-sd (Intercept) 0.563
Fixed Effects:
(Intercept) 0.007 0.004 0.012 0.002 −18.198 inf <.001 ***
Aged 2.010 0.995 4.060 0.721 1.947 inf 0.05157 .
Spaceflight 2.773 1.247 6.169 1.131 2.500 inf 0.01241 *
CT_Endothelial 1.474 0.849 2.561 0.415 1.378 inf 0.1682
CT_Microglial 1.245 0.832 1.862 0.256 1.066 inf 0.2863
CT_Neuron 1.219 0.960 1.546 0.148 1.628 inf 0.1036
CT_OPC 0.773 0.505 1.182 0.168 −1.187 inf 0.2351
CT_Oligodendrocyte 0.820 0.615 1.095 0.121 −1.344 inf 0.1788
Aged:Spaceflight 0.843 0.307 2.314 0.434 −0.332 inf 0.7399
Spaceflight:CT_Endothelial 0.359 0.108 1.195 0.220 −1.669 inf 0.09505 .
Spaceflight:CT_Microglial 0.707 0.399 1.252 0.206 −1.190 inf 0.234
Spaceflight:CT_Neuron 0.782 0.553 1.104 0.138 −1.400 inf 0.1616
Spaceflight:CT_OPC 0.878 0.475 1.624 0.275 −0.414 inf 0.6788
Spaceflight:CT_Oligodendrocyte 0.813 0.539 1.226 0.170 −0.989 inf 0.3225
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
ANOVA (Type III tests)
model term df1 df2 F_ratio Chisq p_value
Aged 1.000 inf 0.018 0.018 0.8941
Spaceflight 1.000 inf 0.000 0.000 0.9899
CT_ 5.000 inf 5.372 26.860 <.001 ***
Aged:Spaceflight 1.000 inf 0.005 0.005 0.9463
Aged:CT_ 5.000 inf 4.709 23.545 <.001 ***
Spaceflight:CT_ 5.000 inf 0.225 1.125 0.9517
Aged:Spaceflight:CT_ 5.000 inf 1.298 6.490 0.2616
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
Formula: glmer(Senescent_Cell~Aged*Spaceflight*CT_+(1|sample))
Family: binomial (link: default)
Number of observations: 103274
Confidence intervals: parametric
---------------------
Log-likelihood: -9661
AIC: 19373 | BIC: 19612
Residual error: 1.0
Random Effects: Estimate CI-low CI-high SE Z-stat df p
sample-sd (Intercept) 0.564
Fixed Effects:
(Intercept) 0.008 0.005 0.016 0.003 −14.872 inf <.001 ***
Aged 1.558 0.627 3.867 0.723 0.955 inf 0.3394
Spaceflight 2.097 0.821 5.356 1.003 1.548 inf 0.1217
CT_Endothelial 0.886 0.363 2.164 0.404 −0.266 inf 0.79
CT_Microglial 0.959 0.473 1.944 0.346 −0.116 inf 0.9077
CT_Neuron 0.922 0.615 1.384 0.191 −0.391 inf 0.696
CT_OPC 0.808 0.427 1.528 0.263 −0.657 inf 0.5111
CT_Oligodendrocyte 1.052 0.670 1.653 0.242 0.221 inf 0.8254
Aged:Spaceflight 1.346 0.372 4.876 0.884 0.453 inf 0.6507
Aged:CT_Endothelial 3.136 0.887 11.084 2.020 1.774 inf 0.07607 .
Aged:CT_Microglial 1.561 0.624 3.908 0.731 0.952 inf 0.3413
Aged:CT_Neuron 1.553 0.903 2.671 0.430 1.591 inf 0.1116
Aged:CT_OPC 0.821 0.308 2.189 0.411 −0.394 inf 0.6936
Aged:CT_Oligodendrocyte 0.581 0.305 1.106 0.191 −1.653 inf 0.09825 .
Spaceflight:CT_Endothelial 0.000 0.000 111,405,869,631,547,604,087,818,516,773,174,609,728,473,284,365,593,369,837,211,609,575,012,794,270,753,167,976,268,750,705,917,952.000 0.010 −0.078 inf 0.9376
Spaceflight:CT_Microglial 1.219 0.466 3.185 0.597 0.403 inf 0.6867
Spaceflight:CT_Neuron 1.119 0.612 2.046 0.345 0.364 inf 0.7159
Spaceflight:CT_OPC 0.971 0.354 2.664 0.500 −0.056 inf 0.955
Spaceflight:CT_Oligodendrocyte 0.871 0.448 1.696 0.296 −0.406 inf 0.685
Aged:Spaceflight:CT_Endothelial 2,592.647 0.000 3,470,525,015,620,308,636,691,787,938,331,072,880,123,331,428,842,502,710,563,748,259,550,357,545,493,638,604,971,004,467,844,966,489,522,176.000 311,064.284 0.066 inf 0.9478
Aged:Spaceflight:CT_Microglial 0.394 0.112 1.389 0.253 −1.448 inf 0.1476
Aged:Spaceflight:CT_Neuron 0.561 0.258 1.221 0.222 −1.457 inf 0.1451
Aged:Spaceflight:CT_OPC 0.965 0.240 3.886 0.686 −0.050 inf 0.9604
Aged:Spaceflight:CT_Oligodendrocyte 0.985 0.399 2.431 0.454 −0.033 inf 0.9737
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
                                              OR         P  Log-Odds Significance
Term                                                                             
(Intercept)                             0.008471       0.0 -4.771158          ***
Aged                                    1.557754  0.339353  0.443245             
Spaceflight                             2.096864   0.12174  0.740443             
CT_Endothelial                          0.885702  0.790006 -0.121375             
CT_Microglial                           0.959074  0.907739 -0.041787             
CT_Neuron                               0.922298  0.696048 -0.080886             
CT_OPC                                  0.807503  0.511099 -0.213809             
CT_Oligodendrocyte                      1.052152  0.825401  0.050837             
Aged:Spaceflight                        1.346216  0.650713  0.297298             
Aged:CT_Endothelial                     3.135627  0.076072  1.142829             
Aged:CT_Microglial                      1.561155  0.341331  0.445426             
Aged:CT_Neuron                          1.552897  0.111627  0.440122             
Aged:CT_OPC                              0.82106  0.693563 -0.197159             
Aged:CT_Oligodendrocyte                 0.580681  0.098248 -0.543554             
Spaceflight:CT_Endothelial              0.000084  0.937622 -9.389251             
Spaceflight:CT_Microglial               1.218564   0.68672  0.197673             
Spaceflight:CT_Neuron                   1.118644  0.715863  0.112117             
Spaceflight:CT_OPC                      0.971351  0.954966 -0.029067             
Spaceflight:CT_Oligodendrocyte          0.871252  0.685007 -0.137824             
Aged:Spaceflight:CT_Endothelial      2592.647409  0.947764  7.860435             
Aged:Spaceflight:CT_Microglial           0.39447  0.147619 -0.930213             
Aged:Spaceflight:CT_Neuron              0.561191  0.145086 -0.577694             
Aged:Spaceflight:CT_OPC                 0.965304  0.960361 -0.035313             
Aged:Spaceflight:CT_Oligodendrocyte     0.984909  0.973682 -0.015206             
Out[39]:
Analysis of Deviance Table
Model 1: glmer(Senescent_Cell~Aged+SpaceflightCT_+(1|sample))
Model 2: glmer(Senescent_Cell~Aged
Spaceflight+SpaceflightCT_+(1|sample))
Model 3: glmer(Senescent_Cell~Aged
Spaceflight*CT_+(1|sample))
AIC BIC logLik npar -2*log(L) Chisq Df Pr(>Chisq)
1.00 19385.3 19518.9 −9678.6 14.00 19.36K
2.00 19387.2 19530.4 −9678.6 15.00 19.36K 0.10 1.00 0.754
3.00 19373.8 19612.4 −9661.9 25.00 19.32K 33.39 10.00 <.001 ***
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1

Burden (Percent SnC)¶

ANOVA: Percent SnCs across (a) Condition x Age and (b) Condition x Age x Cell Type

In [36]:
# Age + Condition
model_1 = lm(
    f"Senescent_Cell_Burden ~ {col_condition} + {col_age}", data=r_dff)
model_1.set_factors(factors)
model_1.anova(summary=True).show()
model_1.summary().show()

# Age + Condition +  Cell Type
model_2 = lm(
    f"Senescent_Cell_Burden ~ {col_condition} + {col_age} + {col_celltype}",
    data=r_dff)
model_2.set_factors(factors)
model_2.anova(summary=True).show()
model_2.summary().show()

# Age + Condition * Cell Type
model_3 = lm(
    f"Senescent_Cell_Burden ~ {col_age} + {col_condition} * {col_celltype}",
    data=r_dff)
model_3.set_factors(factors)
model_3.anova(summary=True).show()

# # Age * Condition * Cell Type
# model_4 = lm(
#     f"Senescent_Cell_Burden ~ {col_age} * {col_condition} * {col_celltype}",
#     data=r_dff)
# model_4.set_factors(factors)
# model_4.anova(summary=True).show()
# model_4.summary().show()

# Compare
# compare(model_1, model_2, model_3, model_4).show()
for x in [model_1, model_2, model_3]:
    x.summary().show()
compare(model_1, model_2, model_3).show()
ANOVA (Type III tests)
model term df1 df2 F_ratio p_value
Condition 1 104 1.634 0.204
Age_End 1 104 5.018 0.02722 *
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
Formula: lm(Senescent_Cell_Burden~Condition+Age_End)
Number of observations: 107
Confidence intervals: parametric
---------------------
R-squared: 0.0657
R-squared-adj: 0.0478
F(2, 104) = 3.659, p = 0.0291
Log-likelihood: -202
AIC: 412 | BIC: 422
Residual error: 1.623
Estimate SE CI-low CI-high T-stat df p
(Intercept) 1.111 0.262 0.592 1.630 4.246 104 <.001 ***
ConditionSpace Flight 0.403 0.316 −0.222 1.029 1.278 104 0.204
Age_End37 Weeks 0.707 0.316 0.081 1.333 2.240 104 0.02722 *
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
ANOVA (Type III tests)
model term df1 df2 F_ratio p_value
Condition 1 99 1.598 0.2092
Age_End 1 99 4.947 0.0284 *
annotation_scanvi_collapsed 5 99 0.943 0.4571
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
Formula: lm(Senescent_Cell_Burden~Condition+Age_End+annotation_scanvi_collapsed)
Number of observations: 107
Confidence intervals: parametric
---------------------
R-squared: 0.1082
R-squared-adj: 0.0451
F(7, 99) = 1.716, p = 0.1139
Log-likelihood: -199
AIC: 417 | BIC: 441
Residual error: 1.626
Estimate SE CI-low CI-high T-stat df p
(Intercept) 1.230 0.438 0.362 2.099 2.810 99 0.005968 **
ConditionSpace Flight 0.400 0.316 −0.228 1.027 1.264 99 0.2092
Age_End37 Weeks 0.703 0.316 0.076 1.330 2.224 99 0.0284 *
annotation_scanvi_collapsedEndothelial −0.344 0.550 −1.435 0.747 −0.626 99 0.5331
annotation_scanvi_collapsedMicroglial 0.103 0.542 −0.973 1.178 0.189 99 0.8502
annotation_scanvi_collapsedNeuron 0.462 0.542 −0.614 1.537 0.852 99 0.3963
annotation_scanvi_collapsedOPC −0.402 0.542 −1.477 0.674 −0.741 99 0.4603
annotation_scanvi_collapsedOligodendrocyte −0.524 0.542 −1.599 0.551 −0.967 99 0.336
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
ANOVA (Type III tests)
model term df1 df2 F_ratio p_value
Age_End 1 94 4.934 0.02873 *
Condition 1 94 1.532 0.2189
annotation_scanvi_collapsed 5 94 1.030 0.4049
Condition:annotation_scanvi_collapsed 5 94 1.987 0.08766 .
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
Formula: lm(Senescent_Cell_Burden~Condition+Age_End)
Number of observations: 107
Confidence intervals: parametric
---------------------
R-squared: 0.0657
R-squared-adj: 0.0478
F(2, 104) = 3.659, p = 0.0291
Log-likelihood: -202
AIC: 412 | BIC: 422
Residual error: 1.623
Estimate SE CI-low CI-high T-stat df p
(Intercept) 1.111 0.262 0.592 1.630 4.246 104 <.001 ***
ConditionSpace Flight 0.403 0.316 −0.222 1.029 1.278 104 0.204
Age_End37 Weeks 0.707 0.316 0.081 1.333 2.240 104 0.02722 *
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
Formula: lm(Senescent_Cell_Burden~Condition+Age_End+annotation_scanvi_collapsed)
Number of observations: 107
Confidence intervals: parametric
---------------------
R-squared: 0.1082
R-squared-adj: 0.0451
F(7, 99) = 1.716, p = 0.1139
Log-likelihood: -199
AIC: 417 | BIC: 441
Residual error: 1.626
Estimate SE CI-low CI-high T-stat df p
(Intercept) 1.230 0.438 0.362 2.099 2.810 99 0.005968 **
ConditionSpace Flight 0.400 0.316 −0.228 1.027 1.264 99 0.2092
Age_End37 Weeks 0.703 0.316 0.076 1.330 2.224 99 0.0284 *
annotation_scanvi_collapsedEndothelial −0.344 0.550 −1.435 0.747 −0.626 99 0.5331
annotation_scanvi_collapsedMicroglial 0.103 0.542 −0.973 1.178 0.189 99 0.8502
annotation_scanvi_collapsedNeuron 0.462 0.542 −0.614 1.537 0.852 99 0.3963
annotation_scanvi_collapsedOPC −0.402 0.542 −1.477 0.674 −0.741 99 0.4603
annotation_scanvi_collapsedOligodendrocyte −0.524 0.542 −1.599 0.551 −0.967 99 0.336
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
Formula: lm(Senescent_Cell_Burden~Age_End+Condition*annotation_scanvi_collapsed)
Number of observations: 107
Confidence intervals: parametric
---------------------
R-squared: 0.1934
R-squared-adj: 0.0905
F(12, 94) = 1.879, p = 0.0468
Log-likelihood: -194
AIC: 416 | BIC: 453
Residual error: 1.587
Estimate SE CI-low CI-high T-stat df p
(Intercept) 1.036 0.546 −0.048 2.121 1.897 94 0.0609 .
Age_End37 Weeks 0.685 0.309 0.073 1.298 2.221 94 0.02873 *
ConditionSpace Flight 0.805 0.749 −0.682 2.291 1.075 94 0.2851
annotation_scanvi_collapsedEndothelial 0.792 0.748 −0.693 2.277 1.059 94 0.2922
annotation_scanvi_collapsedMicroglial 0.366 0.748 −1.120 1.851 0.489 94 0.6262
annotation_scanvi_collapsedNeuron 0.033 0.748 −1.452 1.518 0.044 94 0.9652
annotation_scanvi_collapsedOPC −0.334 0.748 −1.819 1.151 −0.447 94 0.6562
annotation_scanvi_collapsedOligodendrocyte −0.352 0.748 −1.837 1.133 −0.470 94 0.6391
ConditionSpace Flight:annotation_scanvi_collapsedEndothelial −2.390 1.074 −4.523 −0.257 −2.225 94 0.02847 *
ConditionSpace Flight:annotation_scanvi_collapsedMicroglial −0.526 1.058 −2.626 1.574 −0.497 94 0.6202
ConditionSpace Flight:annotation_scanvi_collapsedNeuron 0.858 1.058 −1.242 2.958 0.811 94 0.4194
ConditionSpace Flight:annotation_scanvi_collapsedOPC −0.135 1.058 −2.236 1.965 −0.128 94 0.8984
ConditionSpace Flight:annotation_scanvi_collapsedOligodendrocyte −0.344 1.058 −2.444 1.756 −0.325 94 0.7457
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
Analysis of Deviance Table
Model 1: lm(Senescent_Cell_Burden~Condition+Age_End)
Model 2: lm(Senescent_Cell_Burden~Condition+Age_End+annotation_scanvi_collapsed)
Model 3: lm(Senescent_Cell_Burden~Age_End+Condition*annotation_scanvi_collapsed)
AIC BIC logLik Res_Df RSS Df Sum of Sq F Pr(>F)
1.00 412.3 423 −202.2 104.00 274.10
2.00 417.3 441.4 −199.7 99.00 261.64 5.00 12.46 0.99 0.428
3.00 416.6 454 −194.3 94.00 236.64 5.00 25.01 1.99 0.0877 .
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1

Just Age as Predictor¶

In [ ]:
# model_cac_mlm_i3_a = lmer(
#     f"senscore ~  {col_age} * {col_celltype} + (1 | {col_sample})",
#     data=r_rna)  # set up model
# model_cac_mlm_i3_a.set_factors(factors)
# model_cac_mlm_i3_a.set_transforms({"senscore": "zscore"})
# model_cac_mlm_i3_a.fit()
# model_cac_mlm_i3_a.summary().show()

# fff = str(f"Senescent_Cell ~ Aged * {col_celltype} + "
#           "(1 | sample)")
# glmmod_ct2a = glmer(fff, data=r_rna, family="binomial")
# glmmod_ct2a.fit(exponentiate=True, ncpus=ncpus)  # estimates => odds
# glmmod_ct2a.summary().show()

Lower SnC Threshold¶

In [17]:
# Column for Lower Threshold Classification
chp = f"Senescent_Cell_{use_metric}_{p_h}"  # column name

# Cell Type Random Effects
fff = str(f"{chp} ~ Aged * Spaceflight"
          f" + (1 | {col_sample}) + (1 + Spaceflight + Aged || CT_)")
glmmod_lenient_thresh = glmer(fff, data=r_rna, family="binomial")
glmmod_lenient_thresh.fit(exponentiate=True, ncpus=ncpus)  # => odds
glmmod_lenient_thresh.summary().show()

# Cell Type as Moderator
fff = str(f"{chp} ~ Aged * Spaceflight * CT_ + (1 | {col_sample})")
glmmod_lenient_thresh_ct = glmer(fff, data=r_rna, family="binomial")
glmmod_lenient_thresh_ct.fit(exponentiate=True, ncpus=ncpus)  # => odds
glmmod_lenient_thresh_ct.summary().show()
R messages: 
boundary (singular) fit: see help('isSingular')

R messages: 
boundary (singular) fit: see help('isSingular')

R messages: 
boundary (singular) fit: see help('isSingular')

Formula: glmer(Senescent_Cell_senmayo_3~Aged*Spaceflight+(1|sample)+(1+Spaceflight+Aged||CT_))
Family: binomial (link: default)
Number of observations: 103274
Confidence intervals: parametric
---------------------
Log-likelihood: -20377
AIC: 40771 | BIC: 40847
Residual error: 1.0
Random Effects: Estimate CI-low CI-high SE Z-stat df p
sample-sd (Intercept) 0.472
CT_-sd (Intercept) 0.000
CT_.1-sd Spaceflight 0.076
CT_.2-sd Aged 0.206
Fixed Effects:
(Intercept) 0.027 0.019 0.039 0.005 −19.267 inf <.001 ***
Aged 1.624 0.919 2.870 0.472 1.668 inf 0.09525 .
Spaceflight 1.966 1.112 3.474 0.571 2.326 inf 0.02003 *
Aged:Spaceflight 0.775 0.375 1.603 0.287 −0.688 inf 0.4917
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
R messages: 
Convergence status
: [1] FALSE
attr(,"gradient")
[1] 0.002085284

R messages: 
Convergence status
: [1] FALSE
attr(,"gradient")
[1] 0.002085284

Formula: glmer(Senescent_Cell_senmayo_3~Aged*Spaceflight*CT_+(1|sample))
Family: binomial (link: default)
Number of observations: 103274
Confidence intervals: parametric
---------------------
Log-likelihood: -20360
AIC: 40770 | BIC: 41008
Residual error: 1.0
Random Effects: Estimate CI-low CI-high SE Z-stat df p
sample-sd (Intercept) 0.472
Fixed Effects:
(Intercept) 0.027 0.017 0.044 0.007 −14.918 inf <.001 ***
Aged 1.400 0.697 2.811 0.498 0.946 inf 0.344
Spaceflight 2.027 1.001 4.107 0.730 1.961 inf 0.04984 *
CT_Endothelial 0.858 0.496 1.486 0.240 −0.546 inf 0.5853
CT_Microglial 0.965 0.634 1.467 0.206 −0.168 inf 0.8664
CT_Neuron 0.953 0.750 1.211 0.117 −0.395 inf 0.693
CT_OPC 0.857 0.588 1.249 0.165 −0.804 inf 0.4217
CT_Oligodendrocyte 1.073 0.822 1.401 0.146 0.522 inf 0.602
Aged:Spaceflight 1.149 0.427 3.088 0.580 0.274 inf 0.7837
Aged:CT_Endothelial 2.331 1.011 5.375 0.994 1.986 inf 0.04708 *
Aged:CT_Microglial 1.144 0.638 2.048 0.340 0.451 inf 0.6518
Aged:CT_Neuron 1.609 1.157 2.238 0.271 2.827 inf 0.004693 **
Aged:CT_OPC 0.925 0.520 1.649 0.273 −0.263 inf 0.7926
Aged:CT_Oligodendrocyte 0.779 0.532 1.141 0.151 −1.284 inf 0.1993
Spaceflight:CT_Endothelial 0.398 0.050 3.145 0.420 −0.874 inf 0.382
Spaceflight:CT_Microglial 0.954 0.531 1.714 0.285 −0.158 inf 0.8747
Spaceflight:CT_Neuron 0.956 0.669 1.366 0.174 −0.248 inf 0.8045
Spaceflight:CT_OPC 1.157 0.655 2.043 0.336 0.503 inf 0.6153
Spaceflight:CT_Oligodendrocyte 0.839 0.567 1.242 0.168 −0.877 inf 0.3807
Aged:Spaceflight:CT_Endothelial 0.755 0.076 7.555 0.888 −0.239 inf 0.8113
Aged:Spaceflight:CT_Microglial 0.735 0.329 1.640 0.301 −0.753 inf 0.4516
Aged:Spaceflight:CT_Neuron 0.609 0.378 0.983 0.149 −2.031 inf 0.04229 *
Aged:Spaceflight:CT_OPC 0.693 0.304 1.580 0.291 −0.872 inf 0.3834
Aged:Spaceflight:CT_Oligodendrocyte 0.894 0.519 1.541 0.248 −0.403 inf 0.6872
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1

Perturbation Distance¶

In [19]:
print(f"\n\n{'=' * 80}\nOverall Distance\n{'=' * 80}\n\n")
df_distance, figs_distance = scflow.ax.analyze_perturbation_distance(
    self.rna, col_condition=[col_age, col_condition, col_batch])

print(f"\n\n{'=' * 80}\nJust Senescence Genes\n{'=' * 80}\n\n")
df_distance_snc, figs_distance_snc = scflow.ax.analyze_perturbation_distance(
    self.rna[:, genes], col_condition=[
        col_age, col_condition, col_batch])
Output()

================================================================================
Overall Distance
================================================================================



Output()

Output()

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

================================================================================
Just Senescence Genes
================================================================================


Output()

Output()

Output()

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

Composition Analysis¶

Cell Type¶

In [ ]:
# print(f"\n\n{'=' * 80}\nOverall Sample\n{'=' * 80}\n\n")
# out_ctc = scflow.ax.analyze_composition(
#     self.rna, col_celltype, col_batch, col_sample=col_sample,
#     palette=palette[col_batch],
#     formula=None, key_modality="coda", reference_cell_type="automatic",
#     absence_threshold=0.1, est_fdr=0.1, level_order=[keys[
#         col_batch]["key_control"]] + keys[col_batch]["key_treatment"])
# plt.show()

# print(f"\n\n{'=' * 80}\nAged Subset\n{'=' * 80}\n\n")
# out_ctc_sf = scflow.ax.analyze_composition(
#     self.rna[self.rna.obs[col_age] != keys[col_age]["key_control"]],
#     col_celltype, col_condition, col_sample=col_sample,
#     formula=None, key_modality="coda", reference_cell_type="automatic",
#     absence_threshold=0.1, est_fdr=0.1, level_order=[keys[col_condition][
#         "key_control"]] + [keys[col_condition]["key_treatment"]])

Senescent Cells¶

Tree-Aggregated¶

In [178]:
# Setup
# col_celltype_hierarchy = [
#     f"{col_celltype}_hierarchical", "SnC_hierarchy"]
col_celltype_hierarchy = [
    "Senescent_Cell", f"{col_celltype}_hierarchical", "SnC_hierarchy",
    "Senescent_Cell_Label_by_Type"]
# col_celltype_hierarchy = [
#     "Senescent_Cell_Label", f"SnC_hierarchy",
#     "Senescent_Cell_Label_by_Type"]
ref_celltype = self.rna.obs[col_celltype_hierarchy[-1]].value_counts(
    ).index.values[0]
form_c = " + ".join([col_condition, col_age]) + " + " + " * ".join([
    col_condition, col_age])

# By SF vs. GC (No Age)
_ = scflow.ax.analyze_composition_tree(
    self.rna, col_celltype_hierarchy[-1], col_condition,
    col_sample=col_sample, formula=None, seed=0, est_fdr=0.2,
    reference_cell_type=ref_celltype, num_warmup=2000,
    col_celltype_hierarchy=col_celltype_hierarchy)

# By SF & Age
_ = scflow.ax.analyze_composition_tree(
    self.rna, col_celltype_hierarchy[-1], [col_condition, col_age],
    formula=form_c, col_sample=col_sample, seed=0,
    reference_cell_type=ref_celltype, est_fdr=0.2,
    col_celltype_hierarchy=col_celltype_hierarchy)
• Zero counts encountered in data! Added a pseudocount of 0.5.
sample: 100%|█| 12000/12000 [01:54<00:00, 104.99it/s, 31 steps of size 1.63e-01
                                          Compositional Analysis summary                                           
┌──────────────────────────────────┬──────────────────────────────────────────────────────────────────────────────┐
│ Name                             │ Value                                                                        │
├──────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────┤
│ Data                             │ Data: 18 samples, 12 cell types                                              │
│ Reference cell type              │ Neuron                                                                       │
│ Formula                          │ Condition                                                                    │
│ Reference index                  │ [3, 0]                                                                       │
│ MCMC Sampling                    │ Sampled 10000 chain states (2000 burnin samples)                             │
│ Acceptance rate                  │ 93.3%                                                                        │
└──────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                               Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                           │
│ Senescent_Cell_Label_by_Type                                                                                    │
│ Astrocyte                          2.299        2.014   2.588  0.155      410.043                               │
│ Endothelial                       -0.027       -0.487   0.458  0.250       40.055                               │
│ Microglial                         1.605        1.310   1.895  0.158      204.847                               │
│ Neuron                             4.495        4.265   4.739  0.127     3685.868                               │
│ OPC                                1.646        1.337   1.938  0.160      213.420                               │
│ Oligodendrocyte                    3.227        2.967   3.476  0.137     1037.180                               │
│ SnC Astrocyte                     -0.818       -1.263  -0.349  0.247       18.161                               │
│ SnC Endothelial                   -1.451       -1.914  -0.973  0.255        9.643                               │
│ SnC Microglial                    -1.078       -1.549  -0.628  0.248       14.003                               │
│ SnC Neuron                         0.492        0.117   0.853  0.196       67.307                               │
│ SnC OPC                           -1.221       -1.705  -0.767  0.250       12.137                               │
│ SnC Oligodendrocyte               -0.485       -0.906  -0.036  0.234       25.337                               │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                     Effect  Expected Sample  log2-fold change                                   │
│ Covariate      Cell Type                                                                                        │
│ T.Space Flight Astrocyte            0.000       410.043           0.000                                         │
│                Endothelial          0.000        40.055           0.000                                         │
│                Microglial           0.000       204.847           0.000                                         │
│                Neuron               0.000      3685.868           0.000                                         │
│                OPC                  0.000       213.420           0.000                                         │
│                Oligodendrocyte      0.000      1037.180           0.000                                         │
│                SnC Astrocyte        0.000        18.161           0.000                                         │
│                SnC Endothelial      0.000         9.643           0.000                                         │
│                SnC Microglial       0.000        14.003           0.000                                         │
│                SnC Neuron           0.000        67.307           0.000                                         │
│                SnC OPC              0.000        12.137           0.000                                         │
│                SnC Oligodendrocyte  0.000        25.337           0.000                                         │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                     Median  HDI 3%  HDI 97%   SD                                                │
│ Covariate      Cell Type                                                                                        │
│ T.Space Flight Astrocyte            0.043   -0.185  0.226   0.108                                               │
│                Endothelial          0.012   -0.477  0.220   0.200                                               │
│                Microglial           0.069   -0.072  0.275   0.091                                               │
│                Neuron               0.000    0.000  0.000   0.000                                               │
│                OPC                  0.083   -0.096  0.279   0.098                                               │
│                Oligodendrocyte      0.105   -0.041  0.254   0.079                                               │
│                SnC Astrocyte        0.212   -0.074  0.551   0.167                                               │
│                SnC Endothelial      0.136   -0.130  0.435   0.148                                               │
│                SnC Microglial       0.144   -0.082  0.461   0.144                                               │
│                SnC Neuron           0.186   -0.054  0.528   0.162                                               │
│                SnC OPC              0.214   -0.100  0.542   0.171                                               │
│                SnC Oligodendrocyte  0.218   -0.076  0.550   0.167                                               │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Nodes                                                                                                           │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Covariate=Condition[T.Space Flight]_node                                                                        │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                      Final Parameter  Median  HDI 3%  HDI 97%  SD   Delta  Is credible                          │
│ Node                                                                                                            │
│ False                     0.00         0.00    0.00    0.00   0.00  0.00      False                             │
│ True                      0.00         0.08   -0.06    0.30   0.10  0.12      False                             │
│ Macroglia                 0.00         0.04   -0.08    0.14   0.06  0.12      False                             │
│ Neuron                    0.00         0.00    0.00    0.00   0.00  0.00      False                             │
│ Microglial                0.00         0.07   -0.07    0.28   0.09  0.12      False                             │
│ Endothelial               0.00         0.01   -0.48    0.22   0.20  0.12      False                             │
│ SnC Macroglia             0.00         0.06   -0.10    0.24   0.09  0.12      False                             │
│ SnC Neuron                0.00         0.08   -0.10    0.39   0.14  0.12      False                             │
│ SnC Endothelial           0.00         0.05   -0.15    0.26   0.11  0.12      False                             │
│ SnC Microglial            0.00         0.05   -0.14    0.27   0.10  0.12      False                             │
│ Oligodendrocyte           0.00         0.07   -0.04    0.21   0.07  0.12      False                             │
│ OPC                       0.00         0.05   -0.12    0.20   0.08  0.12      False                             │
│ Astrocyte                 0.00         0.02   -0.21    0.16   0.10  0.12      False                             │
│ SnC OPC                   0.00         0.05   -0.14    0.27   0.10  0.12      False                             │
│ SnC Oligodendrocyte       0.00         0.05   -0.12    0.26   0.10  0.12      False                             │
│ SnC Astrocyte             0.00         0.05   -0.14    0.26   0.10  0.12      False                             │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Wrote file: /home/easlinger/AWG/ADBR/Brain_AWG/Senescence/tree_effect.png
• Zero counts encountered in data! Added a pseudocount of 0.5.
sample: 100%|█| 11000/11000 [02:00<00:00, 91.42it/s, 31 steps of size 1.18e-01.
                                          Compositional Analysis summary                                           
┌──────────────────────────────────┬──────────────────────────────────────────────────────────────────────────────┐
│ Name                             │ Value                                                                        │
├──────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────┤
│ Data                             │ Data: 18 samples, 12 cell types                                              │
│ Reference cell type              │ Neuron                                                                       │
│ Formula                          │ Condition + Age_End + Condition * Age_End                                    │
│ Reference index                  │ [3, 0]                                                                       │
│ MCMC Sampling                    │ Sampled 10000 chain states (1000 burnin samples)                             │
│ Acceptance rate                  │ 94.0%                                                                        │
└──────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                               Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                           │
│ Senescent_Cell_Label_by_Type                                                                                    │
│ Astrocyte                          2.613        2.322   2.929  0.161      460.187                               │
│ Endothelial                        0.131       -0.362   0.646  0.268       38.461                               │
│ Microglial                         1.780        1.458   2.106  0.172      200.063                               │
│ Neuron                             4.642        4.393   4.875  0.129     3500.401                               │
│ OPC                                1.953        1.615   2.257  0.170      237.848                               │
│ Oligodendrocyte                    3.549        3.272   3.815  0.145     1173.367                               │
│ SnC Astrocyte                     -0.753       -1.218  -0.271  0.255       15.889                               │
│ SnC Endothelial                   -1.423       -1.919  -0.898  0.270        8.131                               │
│ SnC Microglial                    -1.034       -1.526  -0.555  0.259       11.997                               │
│ SnC Neuron                         0.554        0.176   0.932  0.201       58.711                               │
│ SnC OPC                           -1.177       -1.670  -0.672  0.268       10.398                               │
│ SnC Oligodendrocyte               -0.403       -0.861   0.068  0.249       22.548                               │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                       Effect  Expected Sample  log2-fold change                 │
│ Covariate                        Cell Type                                                                      │
│ T.Space Flight                   Astrocyte             0.000      460.187            0.000                      │
│                                  Endothelial           0.000       38.461            0.000                      │
│                                  Microglial            0.000      200.063            0.000                      │
│                                  Neuron                0.000     3500.401            0.000                      │
│                                  OPC                   0.000      237.848            0.000                      │
│                                  Oligodendrocyte       0.000     1173.367            0.000                      │
│                                  SnC Astrocyte         0.000       15.889            0.000                      │
│                                  SnC Endothelial       0.000        8.131            0.000                      │
│                                  SnC Microglial        0.000       11.997            0.000                      │
│                                  SnC Neuron            0.000       58.711            0.000                      │
│                                  SnC OPC               0.000       10.398            0.000                      │
│                                  SnC Oligodendrocyte   0.000       22.548            0.000                      │
│ Age_EndT.37 Weeks                Astrocyte            -0.328      364.769           -0.335                      │
│                                  Endothelial           0.000       42.320            0.138                      │
│                                  Microglial            0.000      220.140            0.138                      │
│                                  Neuron                0.000     3851.679            0.138                      │
│                                  OPC                  -0.328      188.531           -0.335                      │
│                                  Oligodendrocyte      -0.328      930.074           -0.335                      │
│                                  SnC Astrocyte         0.000       17.484            0.138                      │
│                                  SnC Endothelial       0.000        8.947            0.138                      │
│                                  SnC Microglial        0.000       13.201            0.138                      │
│                                  SnC Neuron            0.000       64.603            0.138                      │
│                                  SnC OPC               0.000       11.442            0.138                      │
│                                  SnC Oligodendrocyte   0.000       24.810            0.138                      │
│ T.Space Flight:Age_EndT.37 Weeks Astrocyte             0.000      460.187            0.000                      │
│                                  Endothelial           0.000       38.461            0.000                      │
│                                  Microglial            0.000      200.063            0.000                      │
│                                  Neuron                0.000     3500.401            0.000                      │
│                                  OPC                   0.000      237.848            0.000                      │
│                                  Oligodendrocyte       0.000     1173.367            0.000                      │
│                                  SnC Astrocyte         0.000       15.889            0.000                      │
│                                  SnC Endothelial       0.000        8.131            0.000                      │
│                                  SnC Microglial        0.000       11.997            0.000                      │
│                                  SnC Neuron            0.000       58.711            0.000                      │
│                                  SnC OPC               0.000       10.398            0.000                      │
│                                  SnC Oligodendrocyte   0.000       22.548            0.000                      │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                       Median  HDI 3%  HDI 97%   SD                              │
│ Covariate                        Cell Type                                                                      │
│ T.Space Flight                   Astrocyte             0.012  -0.189   0.169  0.092                             │
│                                  Endothelial          -0.025  -0.555   0.131  0.208                             │
│                                  Microglial            0.032  -0.080   0.286  0.097                             │
│                                  Neuron                0.000   0.000   0.000  0.000                             │
│                                  OPC                   0.037  -0.127   0.214  0.088                             │
│                                  Oligodendrocyte       0.076  -0.051   0.246  0.079                             │
│                                  SnC Astrocyte         0.116  -0.152   0.462  0.162                             │
│                                  SnC Endothelial       0.071  -0.178   0.400  0.146                             │
│                                  SnC Microglial        0.078  -0.141   0.411  0.146                             │
│                                  SnC Neuron            0.123  -0.094   0.502  0.167                             │
│                                  SnC OPC               0.119  -0.151   0.473  0.166                             │
│                                  SnC Oligodendrocyte   0.121  -0.155   0.460  0.162                             │
│ Age_EndT.37 Weeks                Astrocyte            -0.321  -0.533  -0.071  0.121                             │
│                                  Endothelial           0.002  -0.300   0.170  0.129                             │
│                                  Microglial           -0.017  -0.319   0.104  0.119                             │
│                                  Neuron                0.000   0.000   0.000  0.000                             │
│                                  OPC                  -0.319  -0.546  -0.049  0.130                             │
│                                  Oligodendrocyte      -0.348  -0.542  -0.158  0.102                             │
│                                  SnC Astrocyte         0.040  -0.263   0.313  0.147                             │
│                                  SnC Endothelial       0.038  -0.206   0.278  0.124                             │
│                                  SnC Microglial        0.036  -0.206   0.273  0.122                             │
│                                  SnC Neuron            0.078  -0.135   0.420  0.152                             │
│                                  SnC OPC               0.041  -0.261   0.322  0.147                             │
│                                  SnC Oligodendrocyte   0.030  -0.277   0.318  0.151                             │
│ T.Space Flight:Age_EndT.37 Weeks Astrocyte             0.011  -0.224   0.177  0.103                             │
│                                  Endothelial           0.003  -0.305   0.162  0.129                             │
│                                  Microglial            0.012  -0.164   0.168  0.081                             │
│                                  Neuron                0.000   0.000   0.000  0.000                             │
│                                  OPC                   0.031  -0.188   0.225  0.104                             │
│                                  Oligodendrocyte       0.030  -0.148   0.205  0.089                             │
│                                  SnC Astrocyte         0.065  -0.219   0.384  0.153                             │
│                                  SnC Endothelial       0.047  -0.189   0.329  0.131                             │
│                                  SnC Microglial        0.048  -0.193   0.318  0.131                             │
│                                  SnC Neuron            0.076  -0.131   0.427  0.151                             │
│                                  SnC OPC               0.067  -0.236   0.373  0.155                             │
│                                  SnC Oligodendrocyte   0.062  -0.246   0.356  0.153                             │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Nodes                                                                                                           │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Covariate=Age_End[T.37 Weeks]_node                                                                              │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                      Final Parameter  Median  HDI 3%  HDI 97%  SD   Delta  Is credible                          │
│ Node                                                                                                            │
│ False                     0.00         0.00    0.00    0.00   0.00  0.00      False                             │
│ True                      0.00         0.02   -0.11    0.19   0.07  0.15      False                             │
│ Macroglia                -0.33        -0.33   -0.55   -0.08   0.12  0.15       True                             │
│ Neuron                    0.00         0.00    0.00    0.00   0.00  0.00      False                             │
│ Microglial                0.00        -0.02   -0.32    0.10   0.12  0.15      False                             │
│ Endothelial               0.00         0.00   -0.30    0.17   0.13  0.15      False                             │
│ SnC Macroglia             0.00         0.01   -0.21    0.16   0.09  0.15      False                             │
│ SnC Neuron                0.00         0.04   -0.10    0.40   0.14  0.15      False                             │
│ SnC Endothelial           0.00         0.01   -0.18    0.21   0.10  0.15      False                             │
│ SnC Microglial            0.00         0.01   -0.20    0.19   0.10  0.15      False                             │
│ Oligodendrocyte           0.00         0.00   -0.22    0.12   0.09  0.15      False                             │
│ OPC                       0.00         0.01   -0.16    0.15   0.08  0.15      False                             │
│ Astrocyte                 0.00         0.01   -0.16    0.15   0.07  0.15      False                             │
│ SnC OPC                   0.00         0.01   -0.19    0.22   0.10  0.15      False                             │
│ SnC Oligodendrocyte       0.00         0.01   -0.22    0.19   0.11  0.15      False                             │
│ SnC Astrocyte             0.00         0.01   -0.19    0.21   0.10  0.15      False                             │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Covariate=Condition[T.Space Flight]:Age_End[T.37 Weeks]_node                                                    │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                      Final Parameter  Median  HDI 3%  HDI 97%  SD   Delta  Is credible                          │
│ Node                                                                                                            │
│ False                     0.00         0.00    0.00    0.00   0.00  0.00      False                             │
│ True                      0.00         0.03   -0.10    0.24   0.09  0.15      False                             │
│ Macroglia                 0.00         0.01   -0.14    0.13   0.07  0.15      False                             │
│ Neuron                    0.00         0.00    0.00    0.00   0.00  0.00      False                             │
│ Microglial                0.00         0.01   -0.16    0.17   0.08  0.15      False                             │
│ Endothelial               0.00         0.00   -0.30    0.16   0.13  0.15      False                             │
│ SnC Macroglia             0.00         0.01   -0.16    0.19   0.09  0.15      False                             │
│ SnC Neuron                0.00         0.03   -0.13    0.33   0.13  0.15      False                             │
│ SnC Endothelial           0.00         0.01   -0.18    0.22   0.10  0.15      False                             │
│ SnC Microglial            0.00         0.01   -0.18    0.21   0.10  0.15      False                             │
│ Oligodendrocyte           0.00         0.02   -0.11    0.16   0.07  0.15      False                             │
│ OPC                       0.00         0.02   -0.15    0.19   0.08  0.15      False                             │
│ Astrocyte                 0.00         0.01   -0.18    0.15   0.08  0.15      False                             │
│ SnC OPC                   0.00         0.01   -0.19    0.21   0.10  0.15      False                             │
│ SnC Oligodendrocyte       0.00         0.01   -0.18    0.21   0.10  0.15      False                             │
│ SnC Astrocyte             0.00         0.01   -0.18    0.20   0.10  0.15      False                             │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Covariate=Condition[T.Space Flight]_node                                                                        │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                      Final Parameter  Median  HDI 3%  HDI 97%  SD   Delta  Is credible                          │
│ Node                                                                                                            │
│ False                     0.00         0.00    0.00    0.00   0.00  0.00      False                             │
│ True                      0.00         0.04   -0.07    0.34   0.11  0.15      False                             │
│ Macroglia                 0.00         0.02   -0.08    0.14   0.06  0.15      False                             │
│ Neuron                    0.00         0.00    0.00    0.00   0.00  0.00      False                             │
│ Microglial                0.00         0.03   -0.08    0.29   0.10  0.15      False                             │
│ Endothelial               0.00        -0.03   -0.56    0.13   0.21  0.15      False                             │
│ SnC Macroglia             0.00         0.02   -0.14    0.22   0.09  0.15      False                             │
│ SnC Neuron                0.00         0.04   -0.13    0.38   0.14  0.15      False                             │
│ SnC Endothelial           0.00         0.01   -0.19    0.20   0.10  0.15      False                             │
│ SnC Microglial            0.00         0.02   -0.17    0.22   0.10  0.15      False                             │
│ Oligodendrocyte           0.00         0.04   -0.06    0.22   0.07  0.15      False                             │
│ OPC                       0.00         0.01   -0.13    0.17   0.07  0.15      False                             │
│ Astrocyte                 0.00        -0.00   -0.20    0.12   0.08  0.15      False                             │
│ SnC OPC                   0.00         0.02   -0.16    0.23   0.10  0.15      False                             │
│ SnC Oligodendrocyte       0.00         0.02   -0.17    0.22   0.10  0.15      False                             │
│ SnC Astrocyte             0.00         0.02   -0.17    0.21   0.10  0.15      False                             │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/pertpy/tools/_coda/_base_coda.py:1990: PerformanceWarning: indexing past lexsort depth may impact performance.
  node_effs = data.uns["scCODA_params"]["node_df"].loc[(covariate + "_node",),].copy()
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/pertpy/tools/_coda/_base_coda.py:2000: PerformanceWarning: indexing past lexsort depth may impact performance.
  leaf_effs = eff_df.loc[(covariate,),].copy()
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/pertpy/tools/_coda/_base_coda.py:1990: PerformanceWarning: indexing past lexsort depth may impact performance.
  node_effs = data.uns["scCODA_params"]["node_df"].loc[(covariate + "_node",),].copy()
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/pertpy/tools/_coda/_base_coda.py:2000: PerformanceWarning: indexing past lexsort depth may impact performance.
  leaf_effs = eff_df.loc[(covariate,),].copy()
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/pertpy/tools/_coda/_base_coda.py:1990: PerformanceWarning: indexing past lexsort depth may impact performance.
  node_effs = data.uns["scCODA_params"]["node_df"].loc[(covariate + "_node",),].copy()
/home/easlinger/miniconda3/envs/rsc/lib/python3.13/site-packages/pertpy/tools/_coda/_base_coda.py:2000: PerformanceWarning: indexing past lexsort depth may impact performance.
  leaf_effs = eff_df.loc[(covariate,),].copy()
Wrote file: /home/easlinger/AWG/ADBR/Brain_AWG/Senescence/tree_effect.png
Wrote file: /home/easlinger/AWG/ADBR/Brain_AWG/Senescence/tree_effect.png
Wrote file: /home/easlinger/AWG/ADBR/Brain_AWG/Senescence/tree_effect.png
<Figure size 0x300 with 0 Axes>
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

scCoda¶

Just by Condition (By Cell Type)¶
In [ ]:
# for x in self.rna.obs[col_celltype].unique():
#     r_s, num_samples, num_warmup = 0, 10000, 2000  # defaults
#     if "annotation_scanvi" in col_celltype:  # avoid bad acceptance rates
#         r_s = 16 if x  == "OPC" else 8675309 if x in [
#             "Microglial"] else r_s  # different random seed
#         if x == "Endothelial":
#             r_s, num_samples, num_warmups = 7654321, 14000, 2000
#     print(f"Seed = {r_s}; {num_samples} samples; {num_samples} warmup")
#     out = scflow.ax.analyze_composition(
#         self.rna[self.rna.obs[col_celltype] == x],
#         "Senescent_Cell_Label_by_Type", col_condition,
#         col_sample=col_sample, formula=None, key_modality="coda",
#         full_hmc=False, palette=palette[col_condition], seed=r_s,
#         num_samples=10000, num_warmup=2000,
#         reference_cell_type=x, absence_threshold=0.1, est_fdr=0.2,
#         level_order=[keys[col_condition]["key_control"], keys[
#             col_condition]["key_treatment"]])
#     f_sccoda_out = f"outputs/sccoda_results_{col_celltype}_{x}_sfgc.pkl"
#     if overwrite is True or os.path.exists(f_sccoda_out) is False:
#         with open(f_sccoda_out, "wb") as f:
#             pickle.dump(out[0], f)
#         # out[1].write_h5mu(
#         #     f"outputs/sccoda_data_{col_celltype}_{x}_sfgc.h5mu")
#     plt.show()
#     del out
By Condition & Age¶
In [ ]:


================================================================================
By Cell Type (by Group)
================================================================================


• Zero counts encountered in data! Added a pseudocount of 0.5.
No description has been provided for this image
sample: 100%|█| 12000/12000 [41:24<00:00,  4.83it/s, 1023 steps of size 2.22e-1
                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 18 samples, 2 cell types                                          │
│ Reference cell type                   │ OPC                                                                     │
│ Formula                               │ Group                                                                   │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 81.0%                                                                   │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                               Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                           │
│ Senescent_Cell_Label_by_Type                                                                                    │
│ OPC                               33.349       33.349  33.349  0.000     199.333                                │
│ SnC OPC                            2.026        2.026   2.026  0.000       0.000                                │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                             Final Parameter  Expected Sample  log2-fold change                  │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks OPC             0.000          199.333              0.000                      │
│                                  SnC OPC         0.000            0.000              0.000                      │
│ GroupT.Space Flight | 20 Weeks   OPC             0.000          199.333              0.000                      │
│                                  SnC OPC        -0.001            0.000             -0.002                      │
│ GroupT.Space Flight | 37 Weeks   OPC             0.000            0.000           -124.658                      │
│                                  SnC OPC       117.730          199.333             45.190                      │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                             HDI 3%  HDI 97%   SD   Inclusion probability                        │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks OPC         0.000   0.000  0.000         0.000                                 │
│                                  SnC OPC       NaN     NaN  0.000         0.000                                 │
│ GroupT.Space Flight | 20 Weeks   OPC         0.000   0.000  0.000         0.000                                 │
│                                  SnC OPC    -0.001  -0.001  0.000         1.000                                 │
│ GroupT.Space Flight | 37 Weeks   OPC         0.000   0.000  0.000         0.000                                 │
│                                  SnC OPC   117.691 117.691  0.000         1.000                                 │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

==================================================   Credible Effects   ==================================================

 Covariate Group[T.Ground Control | 37 Weeks] Group[T.Space Flight | 20 Weeks] Group[T.Space Flight | 37 Weeks]
Cell Type                                                                                                     
OPC                                                                                                           
SnC OPC                                                                     *                                *

==========================================================================================================================



• Zero counts encountered in data! Added a pseudocount of 0.5.
No description has been provided for this image
sample: 100%|█| 12000/12000 [38:40<00:00,  5.17it/s, 1023 steps of size 1.56e-1
                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 17 samples, 2 cell types                                          │
│ Reference cell type                   │ Endothelial                                                             │
│ Formula                               │ Group                                                                   │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 90.1%                                                                   │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                               Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                           │
│ Senescent_Cell_Label_by_Type                                                                                    │
│ Endothelial                       35.456       35.456  35.456  0.000      51.588                                │
│ SnC Endothelial                    3.752        3.752   3.752  0.000       0.000                                │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                   Final Parameter  Expected Sample  log2-fold change            │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks Endothelial           0.000           51.588             0.000                 │
│                                  SnC Endothelial       0.000            0.000             0.000                 │
│ GroupT.Space Flight | 20 Weeks   Endothelial           0.000           51.588             0.000                 │
│                                  SnC Endothelial       0.000            0.000             0.000                 │
│ GroupT.Space Flight | 37 Weeks   Endothelial           0.000            0.000           -26.114                 │
│                                  SnC Endothelial      49.805           51.588            45.739                 │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                   HDI 3%  HDI 97%   SD   Inclusion probability                  │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks Endothelial       0.000   0.000  0.000         0.000                           │
│                                  SnC Endothelial     NaN     NaN  0.000         0.000                           │
│ GroupT.Space Flight | 20 Weeks   Endothelial       0.000   0.000  0.000         0.000                           │
│                                  SnC Endothelial     NaN     NaN  0.000         0.000                           │
│ GroupT.Space Flight | 37 Weeks   Endothelial       0.000   0.000  0.000         0.000                           │
│                                  SnC Endothelial  49.805  49.805  0.000         1.000                           │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

==================================================   Credible Effects   ==================================================

 Covariate       Group[T.Ground Control | 37 Weeks] Group[T.Space Flight | 20 Weeks] Group[T.Space Flight | 37 Weeks]
Cell Type                                                                                                           
Endothelial                                                                                                         
SnC Endothelial                                                                                                    *

==========================================================================================================================



• Zero counts encountered in data! Added a pseudocount of 0.5.
No description has been provided for this image
sample: 100%|█| 12000/12000 [03:41<00:00, 54.10it/s, 63 steps of size 4.11e-02.
                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 18 samples, 2 cell types                                          │
│ Reference cell type                   │ Astrocyte                                                               │
│ Formula                               │ Group                                                                   │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 0.835                                                                   │
│ Spike-and-slab threshold              │ 0.835                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 79.5%                                                                   │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                               Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                           │
│ Senescent_Cell_Label_by_Type                                                                                    │
│ Astrocyte                         5.890        4.245   7.672   0.972     389.978                                │
│ SnC Astrocyte                     1.724        0.285   3.450   0.904       6.050                                │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                 Final Parameter  Expected Sample  log2-fold change              │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks Astrocyte          0.000           389.978             0.000                   │
│                                  SnC Astrocyte      0.000             6.050             0.000                   │
│ GroupT.Space Flight | 20 Weeks   Astrocyte          0.000           389.978             0.000                   │
│                                  SnC Astrocyte      0.000             6.050             0.000                   │
│ GroupT.Space Flight | 37 Weeks   Astrocyte          0.000           384.531            -0.020                   │
│                                  SnC Astrocyte      0.656            11.497             0.926                   │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                 HDI 3%  HDI 97%   SD   Inclusion probability                    │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks Astrocyte       0.000  0.000   0.000         0.000                             │
│                                  SnC Astrocyte  -0.493  0.575   0.163         0.363                             │
│ GroupT.Space Flight | 20 Weeks   Astrocyte       0.000  0.000   0.000         0.000                             │
│                                  SnC Astrocyte  -0.342  0.699   0.198         0.433                             │
│ GroupT.Space Flight | 37 Weeks   Astrocyte       0.000  0.000   0.000         0.000                             │
│                                  SnC Astrocyte  -0.014  1.212   0.394         0.835                             │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

==================================================   Credible Effects   ==================================================

 Covariate     Group[T.Ground Control | 37 Weeks] Group[T.Space Flight | 20 Weeks] Group[T.Space Flight | 37 Weeks]
Cell Type                                                                                                         
Astrocyte                                                                                                         
SnC Astrocyte                                                                                                    *

==========================================================================================================================



In [182]:
print(f"\n\n{'=' * 80}\nBy Cell Type (by Group)\n{'=' * 80}\n\n")
for x in self.rna.obs[col_celltype].unique():
    r_s = 1618
    if "annotation_scanvi" in col_celltype:
        r_s = 32145 if x in ["Neuron"] else 16 if x in [
            "Microglia", "OPC"] else r_s
    out = scflow.ax.analyze_composition(
        self.rna[self.rna.obs[col_celltype] == x],
        "Senescent_Cell_Label_by_Type", col_batch, col_sample=col_sample,
        formula=None, key_modality="coda", full_hmc=False,
        palette=palette[col_batch], seed=r_s,
        num_samples=10000, num_warmup=2000,
        reference_cell_type=x, absence_threshold=0.1, est_fdr=0.2,
        level_order=[keys[col_batch]["key_control"]] + keys[
            col_batch]["key_treatment"])
    f_sccoda_out = f"outputs/sccoda_results_{col_celltype}_{x}.pkl"
    if overwrite is True or os.path.exists(f_sccoda_out) is False:
        with open(f_sccoda_out, "wb") as f:
            pickle.dump(out[0], f)
        # out[1].write_h5mu(f"outputs/sccoda_data_{col_celltype}_{x}.h5mu")
    plt.show()
    del out

# Reload
# out_ctc_ct = {}
# for x in self.rna.obs[col_celltype].unique():
#     with open(f"outputs/sccoda_results_{col_celltype}_{x}.pkl", "rb") as f:
#         tmp = pickle.load(f)
#     out_ctc_ct[x] = [tmp, mudata.read(
#         f"outputs/sccoda_data_{col_celltype}_{x}.h5mu")]
#     del tmp

================================================================================
By Cell Type (by Group)
================================================================================


No description has been provided for this image
sample: 100%|█| 12000/12000 [03:25<00:00, 58.30it/s, 1 steps of size 4.16e-02. 
                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 18 samples, 2 cell types                                          │
│ Reference cell type                   │ Neuron                                                                  │
│ Formula                               │ Group                                                                   │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 76.0%                                                                   │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                               Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                           │
│ Senescent_Cell_Label_by_Type                                                                                    │
│ Neuron                            3.979         3.222  4.725   0.395     3787.418                               │
│ SnC Neuron                        0.124        -0.500  0.727   0.322       80.193                               │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                              Final Parameter  Expected Sample  log2-fold change                 │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks Neuron          0.000           3787.418           0.000                       │
│                                  SnC Neuron      0.000             80.193           0.000                       │
│ GroupT.Space Flight | 20 Weeks   Neuron          0.000           3787.418           0.000                       │
│                                  SnC Neuron      0.000             80.193           0.000                       │
│ GroupT.Space Flight | 37 Weeks   Neuron          0.000           3787.418           0.000                       │
│                                  SnC Neuron      0.000             80.193           0.000                       │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                              HDI 3%  HDI 97%   SD    Inclusion probability                      │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks Neuron       0.000   0.000   0.000         0.000                               │
│                                  SnC Neuron  -0.481   0.762   0.190         0.444                               │
│ GroupT.Space Flight | 20 Weeks   Neuron       0.000   0.000   0.000         0.000                               │
│                                  SnC Neuron  -0.525   0.737   0.198         0.358                               │
│ GroupT.Space Flight | 37 Weeks   Neuron       0.000   0.000   0.000         0.000                               │
│                                  SnC Neuron  -0.041  48.593  14.704         0.607                               │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

==================================================   Credible Effects   ==================================================

 Covariate  Group[T.Ground Control | 37 Weeks] Group[T.Space Flight | 20 Weeks] Group[T.Space Flight | 37 Weeks]
Cell Type                                                                                                      
Neuron                                                                                                         
SnC Neuron                                                                                                     

==========================================================================================================================



• Zero counts encountered in data! Added a pseudocount of 0.5.
No description has been provided for this image
sample: 100%|█| 12000/12000 [03:46<00:00, 53.03it/s, 63 steps of size 4.15e-02.
                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 18 samples, 2 cell types                                          │
│ Reference cell type                   │ Oligodendrocyte                                                         │
│ Formula                               │ Group                                                                   │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 76.2%                                                                   │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                               Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                           │
│ Senescent_Cell_Label_by_Type                                                                                    │
│ Oligodendrocyte                   6.802        5.160   8.430   0.976     1026.945                               │
│ SnC Oligodendrocyte               2.400        0.809   3.940   0.937       12.583                               │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                       Final Parameter  Expected Sample  log2-fold change        │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks Oligodendrocyte          0.000           1026.945           0.000              │
│                                  SnC Oligodendrocyte      0.000             12.583           0.000              │
│ GroupT.Space Flight | 20 Weeks   Oligodendrocyte          0.000           1026.945           0.000              │
│                                  SnC Oligodendrocyte      0.000             12.583           0.000              │
│ GroupT.Space Flight | 37 Weeks   Oligodendrocyte          0.000           1026.945           0.000              │
│                                  SnC Oligodendrocyte      0.000             12.583           0.000              │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                       HDI 3%  HDI 97%   SD   Inclusion probability              │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks Oligodendrocyte       0.000  0.000   0.000         0.000                       │
│                                  SnC Oligodendrocyte  -0.689  0.175   0.178         0.395                       │
│ GroupT.Space Flight | 20 Weeks   Oligodendrocyte       0.000  0.000   0.000         0.000                       │
│                                  SnC Oligodendrocyte  -0.073  0.776   0.249         0.591                       │
│ GroupT.Space Flight | 37 Weeks   Oligodendrocyte       0.000  0.000   0.000         0.000                       │
│                                  SnC Oligodendrocyte  -0.108  0.739   0.226         0.539                       │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

==================================================   Credible Effects   ==================================================

 Covariate           Group[T.Ground Control | 37 Weeks] Group[T.Space Flight | 20 Weeks] Group[T.Space Flight | 37 Weeks]
Cell Type                                                                                                               
Oligodendrocyte                                                                                                         
SnC Oligodendrocyte                                                                                                     

==========================================================================================================================



• Zero counts encountered in data! Added a pseudocount of 0.5.
No description has been provided for this image
sample: 100%|█| 12000/12000 [33:55<00:00,  5.90it/s, 1023 steps of size 1.85e-1
                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 18 samples, 2 cell types                                          │
│ Reference cell type                   │ Microglial                                                              │
│ Formula                               │ Group                                                                   │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 87.2%                                                                   │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                               Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                           │
│ Senescent_Cell_Label_by_Type                                                                                    │
│ Microglial                        35.771       35.771  35.771  0.000     186.722                                │
│ SnC Microglial                     2.377        2.377   2.377  0.000       0.000                                │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                  Final Parameter  Expected Sample  log2-fold change             │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks Microglial           0.000            0.000           -67.961                  │
│                                  SnC Microglial      80.501          186.722            48.177                  │
│ GroupT.Space Flight | 20 Weeks   Microglial           0.000          186.722             0.000                  │
│                                  SnC Microglial       0.000            0.000             0.000                  │
│ GroupT.Space Flight | 37 Weeks   Microglial           0.000          186.722             0.000                  │
│                                  SnC Microglial       0.030            0.000             0.044                  │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                  HDI 3%  HDI 97%   SD   Inclusion probability                   │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks Microglial       0.000   0.000  0.000         0.000                            │
│                                  SnC Microglial  80.501  80.501  0.000         1.000                            │
│ GroupT.Space Flight | 20 Weeks   Microglial       0.000   0.000  0.000         0.000                            │
│                                  SnC Microglial     NaN     NaN  0.000         0.000                            │
│ GroupT.Space Flight | 37 Weeks   Microglial       0.000   0.000  0.000         0.000                            │
│                                  SnC Microglial   0.030   0.030  0.000         1.000                            │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

==================================================   Credible Effects   ==================================================

 Covariate      Group[T.Ground Control | 37 Weeks] Group[T.Space Flight | 20 Weeks] Group[T.Space Flight | 37 Weeks]
Cell Type                                                                                                          
Microglial                                                                                                         
SnC Microglial                                  *                                                                 *

==========================================================================================================================



• Zero counts encountered in data! Added a pseudocount of 0.5.
No description has been provided for this image
sample: 100%|█| 12000/12000 [37:43<00:00,  5.30it/s, 1023 steps of size 2.22e-1
                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 18 samples, 2 cell types                                          │
│ Reference cell type                   │ OPC                                                                     │
│ Formula                               │ Group                                                                   │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 81.0%                                                                   │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                               Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                           │
│ Senescent_Cell_Label_by_Type                                                                                    │
│ OPC                               33.349       33.349  33.349  0.000     199.333                                │
│ SnC OPC                            2.026        2.026   2.026  0.000       0.000                                │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                             Final Parameter  Expected Sample  log2-fold change                  │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks OPC             0.000          199.333              0.000                      │
│                                  SnC OPC         0.000            0.000              0.000                      │
│ GroupT.Space Flight | 20 Weeks   OPC             0.000          199.333              0.000                      │
│                                  SnC OPC        -0.001            0.000             -0.002                      │
│ GroupT.Space Flight | 37 Weeks   OPC             0.000            0.000           -124.658                      │
│                                  SnC OPC       117.730          199.333             45.190                      │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                             HDI 3%  HDI 97%   SD   Inclusion probability                        │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks OPC         0.000   0.000  0.000         0.000                                 │
│                                  SnC OPC       NaN     NaN  0.000         0.000                                 │
│ GroupT.Space Flight | 20 Weeks   OPC         0.000   0.000  0.000         0.000                                 │
│                                  SnC OPC    -0.001  -0.001  0.000         1.000                                 │
│ GroupT.Space Flight | 37 Weeks   OPC         0.000   0.000  0.000         0.000                                 │
│                                  SnC OPC   117.691 117.691  0.000         1.000                                 │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

==================================================   Credible Effects   ==================================================

 Covariate Group[T.Ground Control | 37 Weeks] Group[T.Space Flight | 20 Weeks] Group[T.Space Flight | 37 Weeks]
Cell Type                                                                                                     
OPC                                                                                                           
SnC OPC                                                                     *                                *

==========================================================================================================================



• Zero counts encountered in data! Added a pseudocount of 0.5.
No description has been provided for this image
sample: 100%|█| 12000/12000 [38:58<00:00,  5.13it/s, 1023 steps of size 1.56e-1
                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 17 samples, 2 cell types                                          │
│ Reference cell type                   │ Endothelial                                                             │
│ Formula                               │ Group                                                                   │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 90.1%                                                                   │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                               Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                           │
│ Senescent_Cell_Label_by_Type                                                                                    │
│ Endothelial                       35.456       35.456  35.456  0.000      51.588                                │
│ SnC Endothelial                    3.752        3.752   3.752  0.000       0.000                                │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                   Final Parameter  Expected Sample  log2-fold change            │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks Endothelial           0.000           51.588             0.000                 │
│                                  SnC Endothelial       0.000            0.000             0.000                 │
│ GroupT.Space Flight | 20 Weeks   Endothelial           0.000           51.588             0.000                 │
│                                  SnC Endothelial       0.000            0.000             0.000                 │
│ GroupT.Space Flight | 37 Weeks   Endothelial           0.000            0.000           -26.114                 │
│                                  SnC Endothelial      49.805           51.588            45.739                 │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                   HDI 3%  HDI 97%   SD   Inclusion probability                  │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks Endothelial       0.000   0.000  0.000         0.000                           │
│                                  SnC Endothelial     NaN     NaN  0.000         0.000                           │
│ GroupT.Space Flight | 20 Weeks   Endothelial       0.000   0.000  0.000         0.000                           │
│                                  SnC Endothelial     NaN     NaN  0.000         0.000                           │
│ GroupT.Space Flight | 37 Weeks   Endothelial       0.000   0.000  0.000         0.000                           │
│                                  SnC Endothelial  49.805  49.805  0.000         1.000                           │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

==================================================   Credible Effects   ==================================================

 Covariate       Group[T.Ground Control | 37 Weeks] Group[T.Space Flight | 20 Weeks] Group[T.Space Flight | 37 Weeks]
Cell Type                                                                                                           
Endothelial                                                                                                         
SnC Endothelial                                                                                                    *

==========================================================================================================================



• Zero counts encountered in data! Added a pseudocount of 0.5.
No description has been provided for this image
sample: 100%|█| 12000/12000 [03:40<00:00, 54.50it/s, 63 steps of size 4.11e-02.
                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 18 samples, 2 cell types                                          │
│ Reference cell type                   │ Astrocyte                                                               │
│ Formula                               │ Group                                                                   │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 0.835                                                                   │
│ Spike-and-slab threshold              │ 0.835                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 79.5%                                                                   │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                               Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                           │
│ Senescent_Cell_Label_by_Type                                                                                    │
│ Astrocyte                         5.890        4.245   7.672   0.972     389.978                                │
│ SnC Astrocyte                     1.724        0.285   3.450   0.904       6.050                                │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                 Final Parameter  Expected Sample  log2-fold change              │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks Astrocyte          0.000           389.978             0.000                   │
│                                  SnC Astrocyte      0.000             6.050             0.000                   │
│ GroupT.Space Flight | 20 Weeks   Astrocyte          0.000           389.978             0.000                   │
│                                  SnC Astrocyte      0.000             6.050             0.000                   │
│ GroupT.Space Flight | 37 Weeks   Astrocyte          0.000           384.531            -0.020                   │
│                                  SnC Astrocyte      0.656            11.497             0.926                   │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                 HDI 3%  HDI 97%   SD   Inclusion probability                    │
│ Covariate                        Cell Type                                                                      │
│ GroupT.Ground Control | 37 Weeks Astrocyte       0.000  0.000   0.000         0.000                             │
│                                  SnC Astrocyte  -0.493  0.575   0.163         0.363                             │
│ GroupT.Space Flight | 20 Weeks   Astrocyte       0.000  0.000   0.000         0.000                             │
│                                  SnC Astrocyte  -0.342  0.699   0.198         0.433                             │
│ GroupT.Space Flight | 37 Weeks   Astrocyte       0.000  0.000   0.000         0.000                             │
│                                  SnC Astrocyte  -0.014  1.212   0.394         0.835                             │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

==================================================   Credible Effects   ==================================================

 Covariate     Group[T.Ground Control | 37 Weeks] Group[T.Space Flight | 20 Weeks] Group[T.Space Flight | 37 Weeks]
Cell Type                                                                                                         
Astrocyte                                                                                                         
SnC Astrocyte                                                                                                    *

==========================================================================================================================



Lower SnC Threshold¶
In [184]:
chp = f"Senescent_Cell_Label_by_Type_{use_metric}_{p_h}"  # column name
print("Cross-Tabs of Cell Counts in SnC Classifications "
      f"with Top {percentile}% Threshold versus Top {p_h}%")
print(self.rna.obs[["Senescent_Cell_Label_by_Type", chp]].value_counts(
    ).sort_index(), "\n\n")  # cross-tabs of higher vs. lower SnC threshold
# print(self.rna.obs[["Senescent_Cell_Label_by_Type", chp, col_batch]].groupby(
#     col_batch).value_counts().unstack(0).replace(0, np.nan).dropna(
#         how="all", axis=0).astype(int).sort_index())  # cross-tabs by group
for x in self.rna.obs[col_celltype].unique():
    out = scflow.ax.analyze_composition(
        self.rna[self.rna.obs[col_celltype] == x],
        chp, col_condition, col_sample=col_sample,
        formula=None, key_modality="coda", full_hmc=False,
        palette=palette[col_condition], seed=1618,
        num_samples=10000, num_warmup=2000,
        reference_cell_type=x, absence_threshold=0.1, est_fdr=0.2,
        level_order=[keys[col_condition]["key_control"], keys[
            col_condition]["key_treatment"]])
    f_sccoda = f"outputs/sccoda_results_{col_celltype}_{x}_sfgc_{p_h}pct.pkl"
    if overwrite is True or os.path.exists(f_sccoda) is False:
        with open(f_sccoda, "wb") as f:
            pickle.dump(out[0], f)
        out[1].write_h5mu(
            f"outputs/sccoda_data_{col_celltype}_{x}_sfgc_{p_h}pct.h5mu")
    plt.show()
    del out
Cross-Tabs of Cell Counts in SnC Classifications with Top 1% Threshold versus Top 3%
Senescent_Cell_Label_by_Type  Senescent_Cell_Label_by_Type_senmayo_3
Astrocyte                     Astrocyte                                  6807
                              SnC Astrocyte                               200
Endothelial                   Endothelial                                 836
                              SnC Endothelial                              21
Microglial                    Microglial                                 3210
                              SnC Microglial                               87
Neuron                        Neuron                                    65616
                              SnC Neuron                                 2431
OPC                           OPC                                        3445
                              SnC OPC                                      93
Oligodendrocyte               Oligodendrocyte                           17988
                              SnC Oligodendrocyte                         485
SnC Astrocyte                 SnC Astrocyte                               121
SnC Endothelial               SnC Endothelial                              15
SnC Microglial                SnC Microglial                               63
SnC Neuron                    SnC Neuron                                 1570
SnC OPC                       SnC OPC                                      48
SnC Oligodendrocyte           SnC Oligodendrocyte                         238
Name: count, dtype: int64 


No description has been provided for this image
sample: 100%|█| 12000/12000 [34:25<00:00,  5.81it/s, 1023 steps of size 1.22e-1
                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 18 samples, 2 cell types                                          │
│ Reference cell type                   │ Neuron                                                                  │
│ Formula                               │ Condition                                                               │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 92.9%                                                                   │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                         Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                 │
│ Senescent_Cell_Label_by_Type_senmayo_3                                                                          │
│ Neuron                                      37.299       37.299  37.299  0.000     3867.611                     │
│ SnC Neuron                                   0.055        0.055   0.055  0.000        0.000                     │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                            Final Parameter  Expected Sample  log2-fold change                                   │
│ Covariate      Cell Type                                                                                        │
│ T.Space Flight Neuron           0.000             0.000          -102.417                                       │
│                SnC Neuron     108.234          3867.611            53.732                                       │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                            HDI 3%  HDI 97%   SD   Inclusion probability                                         │
│ Covariate      Cell Type                                                                                        │
│ T.Space Flight Neuron       0.000   0.000  0.000         0.000                                                  │
│                SnC Neuron 108.226 108.226  0.000         1.000                                                  │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

==================================================   Credible Effects   ==================================================

 Covariate  Condition[T.Space Flight]
Cell Type                           
Neuron                              
SnC Neuron                         *

==========================================================================================================================



... storing 'rna:scCODA_sample_id' as categorical
... storing 'scCODA_sample_id' as categorical
No description has been provided for this image
sample: 100%|█| 12000/12000 [01:33<00:00, 128.05it/s, 1 steps of size 6.01e-02.
                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 18 samples, 2 cell types                                          │
│ Reference cell type                   │ Oligodendrocyte                                                         │
│ Formula                               │ Condition                                                               │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 0.908                                                                   │
│ Spike-and-slab threshold              │ 0.908                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 60.1%                                                                   │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                         Final Parameter  HDI 3%  HDI 97%   SD    Expected Sample                │
│ Senescent_Cell_Label_by_Type_senmayo_3                                                                          │
│ Oligodendrocyte                             15.477       5.216   42.203  15.909     1039.487                    │
│ SnC Oligodendrocyte                          4.195       1.927    9.093   2.737        0.013                    │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                     Final Parameter  Expected Sample  log2-fold change                          │
│ Covariate      Cell Type                                                                                        │
│ T.Space Flight Oligodendrocyte           0.000             0.000          -33.324                               │
│                SnC Oligodendrocyte      34.380          1039.500           16.277                               │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                     HDI 3%  HDI 97%   SD    Inclusion probability                               │
│ Covariate      Cell Type                                                                                        │
│ T.Space Flight Oligodendrocyte       0.000   0.000   0.000         0.000                                        │
│                SnC Oligodendrocyte  -0.008  39.799  73.660         0.908                                        │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
... storing 'rna:scCODA_sample_id' as categorical
... storing 'scCODA_sample_id' as categorical

==================================================   Credible Effects   ==================================================

 Covariate           Condition[T.Space Flight]
Cell Type                                    
Oligodendrocyte                              
SnC Oligodendrocyte                         *

==========================================================================================================================



• Zero counts encountered in data! Added a pseudocount of 0.5.
No description has been provided for this image
sample: 100%|█| 12000/12000 [00:26<00:00, 449.49it/s, 1 steps of size 1.14e-01.
! Acceptance rate unusually low (0.03040531919314433 < 0.5)! Results might be incorrect! Please check feasibility of results and re-run the sampling step with a different rng_key if necessary.

                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 18 samples, 2 cell types                                          │
│ Reference cell type                   │ Microglial                                                              │
│ Formula                               │ Condition                                                               │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 0.979                                                                   │
│ Spike-and-slab threshold              │ 0.979                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 3.0%                                                                    │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                         Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                 │
│ Senescent_Cell_Label_by_Type_senmayo_3                                                                          │
│ Microglial                                  4.245        4.251   4.251   0.109     179.269                      │
│ SnC Microglial                              1.061        1.062   1.062   0.090       7.425                      │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                Final Parameter  Expected Sample  log2-fold change                               │
│ Covariate      Cell Type                                                                                        │
│ T.Space Flight Microglial           0.000            0.000           -154.907                                   │
│                SnC Microglial     110.598          186.694              4.652                                   │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                HDI 3%  HDI 97%   SD    Inclusion probability                                    │
│ Covariate      Cell Type                                                                                        │
│ T.Space Flight Microglial       0.000   0.000   0.000         0.000                                             │
│                SnC Microglial 112.415 112.415  21.132         0.979                                             │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
... storing 'rna:scCODA_sample_id' as categorical
... storing 'scCODA_sample_id' as categorical

==================================================   Credible Effects   ==================================================

 Covariate      Condition[T.Space Flight]
Cell Type                               
Microglial                              
SnC Microglial                         *

==========================================================================================================================



No description has been provided for this image
sample: 100%|█| 12000/12000 [28:53<00:00,  6.92it/s, 2 steps of size 2.90e-16. 
                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 18 samples, 2 cell types                                          │
│ Reference cell type                   │ OPC                                                                     │
│ Formula                               │ Condition                                                               │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 84.5%                                                                   │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                         Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                 │
│ Senescent_Cell_Label_by_Type_senmayo_3                                                                          │
│ OPC                                         36.278       36.278  36.278  0.000     199.222                      │
│ SnC OPC                                      2.366        2.366   2.366  0.000       0.000                      │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                           Final Parameter  Expected Sample  log2-fold change                                    │
│ Covariate      Cell Type                                                                                        │
│ T.Space Flight OPC             0.000            0.000           -69.174                                         │
│                SnC OPC        81.860          199.222            48.925                                         │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                           HDI 3%  HDI 97%   SD   Inclusion probability                                          │
│ Covariate      Cell Type                                                                                        │
│ T.Space Flight OPC         0.000   0.000  0.000         0.000                                                   │
│                SnC OPC    81.841  81.841  0.000         1.000                                                   │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
... storing 'rna:scCODA_sample_id' as categorical
... storing 'scCODA_sample_id' as categorical

==================================================   Credible Effects   ==================================================

 Covariate Condition[T.Space Flight]
Cell Type                          
OPC                                
SnC OPC                           *

==========================================================================================================================



• Zero counts encountered in data! Added a pseudocount of 0.5.
No description has been provided for this image
sample: 100%|█| 12000/12000 [36:01<00:00,  5.55it/s, 1023 steps of size 7.84e-1
! Acceptance rate unusually high (0.964199999960805 > 0.95)! Results might be incorrect! Please check feasibility of results and re-run the sampling step with a different rng_key if necessary.

                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 17 samples, 2 cell types                                          │
│ Reference cell type                   │ Endothelial                                                             │
│ Formula                               │ Condition                                                               │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ Spike-and-slab threshold              │ 1.000                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 96.4%                                                                   │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                         Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                 │
│ Senescent_Cell_Label_by_Type_senmayo_3                                                                          │
│ Endothelial                                 37.166       37.166  37.166  0.000      51.500                      │
│ SnC Endothelial                              5.894        5.894   5.894  0.000       0.000                      │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                 Final Parameter  Expected Sample  log2-fold change                              │
│ Covariate      Cell Type                                                                                        │
│ T.Space Flight Endothelial           0.000            0.000           -257.519                                  │
│                SnC Endothelial     209.771           51.500             45.116                                  │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                 HDI 3%  HDI 97%   SD   Inclusion probability                                    │
│ Covariate      Cell Type                                                                                        │
│ T.Space Flight Endothelial       0.000   0.000  0.000         0.000                                             │
│                SnC Endothelial 209.771 209.771  0.000         1.000                                             │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
... storing 'rna:scCODA_sample_id' as categorical
... storing 'scCODA_sample_id' as categorical

==================================================   Credible Effects   ==================================================

 Covariate       Condition[T.Space Flight]
Cell Type                                
Endothelial                              
SnC Endothelial                         *

==========================================================================================================================



• Zero counts encountered in data! Added a pseudocount of 0.5.
No description has been provided for this image
sample: 100%|█| 12000/12000 [00:38<00:00, 308.21it/s, 1 steps of size 6.60e-02.
! Acceptance rate unusually low (0.08084303939918638 < 0.5)! Results might be incorrect! Please check feasibility of results and re-run the sampling step with a different rng_key if necessary.

                                          Compositional Analysis summary                                           
┌───────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────┐
│ Name                                  │ Value                                                                   │
├───────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────┤
│ Data                                  │ Data: 18 samples, 2 cell types                                          │
│ Reference cell type                   │ Astrocyte                                                               │
│ Formula                               │ Condition                                                               │
│ Reference index                       │ 0                                                                       │
│ Spike-and-slab threshold              │ 0.972                                                                   │
│ Spike-and-slab threshold              │ 0.972                                                                   │
│ MCMC Sampling                         │ Sampled 10000 chain states (2000 burnin samples)                        │
│ Acceptance rate                       │ 8.1%                                                                    │
└───────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Intercepts                                                                                                      │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                         Final Parameter  HDI 3%  HDI 97%   SD   Expected Sample                 │
│ Senescent_Cell_Label_by_Type_senmayo_3                                                                          │
│ Astrocyte                                   4.831        4.598   5.163   0.190     377.317                      │
│ SnC Astrocyte                               1.827        1.442   1.915   0.164      18.711                      │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                               Final Parameter  Expected Sample  log2-fold change                                │
│ Covariate      Cell Type                                                                                        │
│ T.Space Flight Astrocyte           0.000            0.000           -87.241                                     │
│                SnC Astrocyte      63.523          396.028             4.404                                     │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Effects Extended                                                                                                │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                               HDI 3%  HDI 97%   SD    Inclusion probability                                     │
│ Covariate      Cell Type                                                                                        │
│ T.Space Flight Astrocyte      0.000    0.000   0.000         0.000                                              │
│                SnC Astrocyte  0.656   68.328  20.361         0.973                                              │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
... storing 'rna:scCODA_sample_id' as categorical
... storing 'scCODA_sample_id' as categorical

==================================================   Credible Effects   ==================================================

 Covariate     Condition[T.Space Flight]
Cell Type                              
Astrocyte                              
SnC Astrocyte                         *

==========================================================================================================================



Differential Gene Expression¶

Mainly using edgeR

Pseudo-Bulk & Examine Covariates¶

In [ ]:
pdata = scflow.tl.create_pseudobulk(
    self.rna, [i for i in [col_sample, col_condition, col_age] if i],
    "Senescent_Cell_Label_by_Type", layer="counts", mode="sum")
pdata.layers["counts"] = pdata.X.copy()
sc.pp.normalize_total(pdata, target_sum=1e6)
sc.pp.log1p(pdata)
sc.pp.pca(pdata)
sc.pl.pca(pdata, color=pdata.obs, ncols=1, size=300)

Overall DEGs by Groups¶

Age¶

In older spaceflight mice compared to younger spaceflight mice

  • 9630013a20Rik (CNS myelination and neural tissue regeneration) is downregulated.
  • mt-Td is upregulated.
In [ ]:
%matplotlib inline

# Overall
print(f"\n\n{'=' * 80}\nOverall Sample\n{'=' * 80}\n\n")
out_edgr_age = scflow.ax.run_deg_edgr(
    self.rna, col_age, col_covariate=None, formula=None,
    **keys[col_age], log2fc_thresh=0, n_top_vars=25,
    col_celltype=col_celltype, col_sample=col_sample,
    fig_title="Age DEGs: Overall Sample\n\n")

# Ground Control Subset
print(f"\n\n{'=' * 80}\nGround Control Subset\n{'=' * 80}\n\n")
out_edgr_age_gc = scflow.ax.run_deg_edgr(
    self.rna[self.rna.obs[col_condition] == keys[
        col_condition]["key_control"]],
    col_age, col_covariate=None, formula=None,
    **keys[col_age], log2fc_thresh=0, n_top_vars=25,
    col_celltype=col_celltype, col_sample=col_sample,
    fig_title="Age DEGs: Just Ground Control\n\n")

# Space Flight Subset
print(f"\n\n{'=' * 80}\nSpace Flight Subset\n{'=' * 80}\n\n")
out_edgr_age_sf = scflow.ax.run_deg_edgr(
    self.rna[self.rna.obs[col_condition] == keys[
        col_condition]["key_treatment"]],
    col_age, col_covariate=None, formula=None, **keys[col_age],
    log2fc_thresh=0, n_top_vars=25, col_celltype=col_celltype,
    col_sample=col_sample, fig_title="Age DEGs: Just Space Flight\n\n")

Condition¶

out_edgr_con_o[0][(out_edgr_con_o[0].adj_p_value < 0.01) & (
    out_edgr_con_o[0].abs_log_fc > 0.5)].sort_values(
        "abs_log_fc", ascending=False)

Among the older mice, Mir6236 was differentially highly expressed in aged spaceflight mice compared to ground control mice (LFC=1.95, adjusted p=2.61e-13 in the overall sample; LFC=2.11, adjusted p=0.000015 in the aged subset). Suppression of this gene has been linked to neuronal morphogenesis (https://pubs.acs.org/doi/abs/10.1021/acsabm.0c01389) and therefore may represent a candidate intervention target.

Il31ra, which has been linked to neuroinflammation (https://advanced.onlinelibrary.wiley.com/doi/pdfdirect/10.1002/advs.202409086), was also more highly expressed in spaceflight mice compared to ground control mice (LFC=1.52, adjusted p<0.001 in the overall sample; LFC=1.53, adjusted p<0.001 in the aged subset).

UBA52, also more highly expressed in spaceflight mice (LFC=1.43, adjusted p<0.001 in the overall sample; LFC=1.45, adjusted p<0.001 in the aged subset), may serve a neuroprotective role: It has been shown underexpressed in PD (https://www.mdpi.com/2073-4409/11/23/3770) and plays a role in neuroautophagy (https://www.tandfonline.com/doi/pdf/10.1080/15548627.2024.2395727). Likewise, Pomp, a gene associated with oxidative stress resistance and protein clearance [CITATION] was also more highly expressed in spaceflight mice. In contrast to past observations of downregulation of Uqcr11 in Alheimer's (https://www.benthamdirect.com/content/journals/car/10.2174/1567205014666170505095921), that gene was differentially highly expressed in spaceflight mice (LFC=1.23 aged subset; LFC=1.44 overall; p<0.001); however, Cmss1, which has been associated with Alzheimer's in APOE4 mice (https://pmc.ncbi.nlm.nih.gov/articles/PMC8064208/), was also more highly expressed in spaceflight mice.

Genes involved in oxidative phosphorylation and the electron transport chain, including Atp5e, Ndufa12, and Uqcr11 were also more highly expressed in spaceflight mice. Uqcr11 has shown an anti-apoptotic and oxidative stress alleviation role in mice (https://www.mdpi.com/2073-4425/16/5/526).

Tpt1 and Rn7sk were also upregulated in spaceflight mice. Tpt1, which is associated with cancer progression, anti-apoptosis, and cell stress response, has been shown to have a potentially bi-directional relationship with cell cycle control gene and canonical senescence marker TP53 (https://www.tandfonline.com/doi/pdf/10.4161/cc.25404). Rn7sk is associated with cellular senescence (https://onlinelibrary.wiley.com/doi/abs/10.1002/jcp.28119) and Alzheimer's (https://www.nature.com/articles/s41598-024-82490-9.pdf).


Pvalb overall sample (LFC=1.61, p=1.25e-11)

Trim17

Cck

Pam16


Mitochondrial/electron transport chain genes whose upregulation has been linked to Parkinson's disease (https://pmc.ncbi.nlm.nih.gov/articles/PMC10259399/pdf/AMS-19-3-131629.pdf) and/or adaptive responses to neurodegeneration in Alheimer's mouse models (https://journals.sagepub.com/doi/abs/10.1177/13872877251314847), including *mt-Atp6, mt-Co1, mt-Cytb mt-Nd2, and mt-Nd5, mt-Nd6...pregulation of *mt-Rnr1, which also showed higher expression in spaceflight aged mice, has been seen in response to ionizing radiation, possibly reflecting increased mitochonrial biogenesis as an adaptive stress response (https://pmc.ncbi.nlm.nih.gov/articles/PMC5555881)**

In [ ]:
# Overall
print(f"\n\n{'=' * 80}\nOverall Sample\n{'=' * 80}\n\n")
out_edgr_con = scflow.ax.run_deg_edgr(
    self.rna, col_condition, col_covariate=None, formula=None,
    **keys[col_condition], log2fc_thresh=0, n_top_vars=25,
    col_celltype=col_celltype, col_sample=col_sample,
    fig_title=f"{col_condition} DEGs (Overall Sample)\n\n")
out_edgr_con_df = out_edgr_con[0][out_edgr_con[
    0].adj_p_value < 0.001].sort_values("abs_log_fc", ascending=False)
goe = out_edgr_con_df.variable[:10].to_list()
print(out_edgr_con_df.iloc[:min(100, out_edgr_con_df.shape[0])], "\n\n", goe)
plt.show()

# Just Old
print(f"\n\n{'=' * 80}\nAged Subset\n{'=' * 80}\n\n")
out_edgr_con_o = scflow.ax.run_deg_edgr(
    self.rna[self.rna.obs[col_age] == keys[col_age]["key_treatment"]],
    col_condition, col_covariate=None, formula=None,
    **keys[col_condition], log2fc_thresh=0, n_top_vars=25,
    col_celltype=col_celltype, col_sample=col_sample,
    fig_title=f"{col_condition} DEGs (Just Aged)\n\n")
plt.show()
out_edgr_con_o_df = out_edgr_con_o[0][out_edgr_con_o[
    0].adj_p_value < 0.001].sort_values("abs_log_fc", ascending=False)
goes = out_edgr_con_o_df.variable[:10].to_list()
print(out_edgr_con_o_df, "\n\n", goes)
_ = self.plot(
    kind=["violin", "matrix"], col_celltype=col_batch, layer="log1p",
    violin=dict(col_wrap=5, hspace=0.25, rotation=45, figsize=(20, 20)),
    matrix=dict(standard_scale="var"), genes=goes)
out_edgr_old_sf_v_gc = out_edgr_con_o_df[0][(
    out_edgr_con_o_df[0].abs_log_fc > 1) & (
        out_edgr_con_o_df[0].adj_p_value < 0.001)].sort_values(
            "adj_p_value", ascending=True)
out_edgr_old_sf_v_gc = out_edgr_old_sf_v_gc.groupby("contrast").apply(
    lambda x: x.sort_values("adj_p_value", ascending=True).iloc[
        :20]).set_index("variable", append=True).reset_index(
            1, drop=True).rename_axis([col_condition, "variable"])
out_edgr_con_compare = out_edgr_con_o_df.set_index("variable")[[
    "log_fc", "adj_p_value"]].join(out_edgr_con_df.set_index("variable")[[
        "log_fc", "adj_p_value"]], how="inner", lsuffix="_Aged_Subset",
                                   rsuffix="_Overall_Sample")
out_edgr_con_compare

Age x Condition¶

Spaceflight effect (main analysis), can visualize at different ages

Chchd2 (related to oxidative phosphorylation, cell migration, apoptosis inhibition, COX regulation, stress adaptation, Parkinson's, Lewy Body diseases, and cancer) was more highly expressed in spaceflight mice (and demonstrated a bigger young versus old difference in spaceflight mice). Spaceflight mice also showed higher expression of several ribosomal proteins (Rps16, Rpl31, Rpl17, Rpl9, Rpl15, Rps15a, Rpl19, Rps7, Rps23, Rpl37, Rps3a1, Rpl29, Rps15, Rps14).

Ndufa4 was also more highly expressed (implicated in cancer and mitochondrial dysfunction, part of the cytochrome c oxidase complex which drives oxidative phosphorylation, adaptation to hypoxia via downregulation of oxygen consumption and suppression of mitochondrial ROS production https://www.cell.com/cell-metabolism/fulltext/S1550-4131(11)00394-9?mobileUi=0) in spaceflight mice, as were other genes involved in ATP production/the electron transport chain and oxidative phosophorylation, including Cox7a2, Uqcr11, Ndufa12, Ndufa4, Ndufc1, Atp5o-1, Atp5e, and Uqcrh (which additionally has been implicated in tumor suppression https://aacrjournals.org/cancerres/article/80/16_Supplement/4795/643367).

In [ ]:
# With Single Label for Age x Condition
print(f"\n\n{'=' * 80}\nGroup (Single Factor)\n{'=' * 80}\n\n")
out_edgr_groups = scflow.ax.run_deg_edgr(
    self.rna, col_batch, col_covariate=None, formula=None,
    **keys[col_batch], col_sample=col_sample,
    log2fc_thresh=0, n_top_vars=25, col_celltype=col_celltype)
print(list(out_edgr_groups[0].variable[:25]))
plt.show()
# _ = self.plot(kind="violin", col_celltype=col_batch,
#               genes=list(out_edgr_groups[0].variable[:25]), layer="scaled",
#               violin=dict(col_wrap=4, hspace=1, rotation=45))
out_edgr_batches = out_edgr_groups[0][(out_edgr_groups[0].abs_log_fc > 1) & (
    out_edgr_groups[0].adj_p_value < 0.001)].sort_values(
        "adj_p_value", ascending=True)
out_edgr_batches_top = out_edgr_batches.groupby("contrast").apply(
    lambda x: x.sort_values("adj_p_value", ascending=True).iloc[
        :20]).set_index("variable", append=True).reset_index(
            1, drop=True).rename_axis([col_condition, "variable"])

# With Contrasts (Age & Condition = Separate Factors)
print(f"\n\n{'=' * 80}\nAge * Condition (2-Factor Contrast)\n{'=' * 80}\n\n")
out_edgr_contrasts = scflow.ax.run_deg_edgr(
    self.rna, col_condition, col_covariate=col_age, formula=None,
    **keys[col_condition], log2fc_thresh=0, n_top_vars=24,
    col_celltype=col_celltype, col_sample=col_sample)
_ = self.plot(
    kind=["violin", "matrix"], col_celltype=col_batch,
    genes=out_edgr_contrasts[0][out_edgr_contrasts[
        0].adj_p_value < 0.001].sort_values(
            "abs_log_fc", ascending=False).variable[:10], layer="log1p",
    violin=dict(col_wrap=5, hspace=0.25, rotation=45, figsize=(20, 20)),
    matrix=dict(standard_scale="var"))

# Condition x Age
# Vulnerability of mice who were older at launch to spaceflight stress
out_edgr_contrasts_age = scflow.ax.run_deg_edgr(
    self.rna, col_age, col_covariate=col_condition, formula=None,
    **keys[col_age], log2fc_thresh=0, n_top_vars=24,
    col_celltype=col_celltype, col_sample=col_sample)

Senescence Gene Contrasts Results¶

In [ ]:
# Genes
sen_genes_in_contrasts = list(set(genes).intersection(
    out_edgr_contrasts[0].variable.unique()))  # senescence genes in contrasts
out_edgr_snc = out_edgr_contrasts[0].set_index(
    "variable").loc[sen_genes_in_contrasts]  # contrast results for snc genes
res_snc_contrast = out_edgr_snc[out_edgr_snc.adj_p_value < 0.01]  # p < 0.01
sig_contrast_genes = list(res_snc_contrast.index.values)  # significant genes

# Plots By Groups; Axis by Cell Types
kws = dict(dot=dict(figsize=(10, 5)), heat=dict(figsize=(15, 15)))
_ = self.plot(kind=["matrix", "dot"], genes=sig_contrast_genes,
              standard_scale="obs", col_celltype=col_celltype,
              by_group=col_batch, **kws)

# Plots By Cell Types; Axis by Groups
# kws = dict(dot=dict(figsize=(10, 5)), heat=dict(figsize=(15, 15)),
#            violin=dict(figsize=(30, 20), col_wrap=4, xlabel=None,
#                        rotation=45, hspace=1, top=0.95))
kws = dict(dot=dict(figsize=(10, 5)), heat=dict(figsize=(15, 15)))
_ = self.plot(kind=["matrix", "dot"], genes=sig_contrast_genes,
              standard_scale="obs", col_celltype=col_batch,
              by_group=col_celltype, **kws)

# Results
print(f"\n{'=' * 80}\nSignificant Senescence Gene Contrasts\n{'=' * 80}\n")
print(sig_contrast_genes)
res_snc_contrast

Snc versus Not (Group=Covariate)¶

In [ ]:
# Group = Covariate
out_edgr_contrasts_snc = scflow.ax.run_deg_edgr(
    self.rna, "Senescent_Cell_Label",
    col_covariate=col_batch, formula=None,
    key_treatment="Senescent", key_control="Non-Senescent",
    log2fc_thresh=0, n_top_vars=24, xlabel_rotation=45,
    hspace=0.5, wspace=0.2, top=0.92, legend_loc="upper right",
    col_celltype=col_celltype, col_sample=col_sample)

SnC versus Not SnC (Group=Subset)¶

In [ ]:
# Aged Subset
subset_old = self.rna.obs[col_age] == keys[col_age]["key_treatment"]

# Old Ground Control SnCs
print(f"\n\n{'=' * 80}\nGround Control (Aged)\n{'=' * 80}\n\n")
subset_gc = self.rna.obs[col_condition] == keys[
    col_condition]["key_control"]
out_edgr_contrasts_snc_gc = scflow.ax.run_deg_edgr(
    self.rna[subset_gc & subset_old], "Senescent_Cell_Label",
    key_treatment="Senescent", top=0.92,
    key_control="Non-Senescent", log2fc_thresh=0, n_top_vars=24,
    xlabel_rotation=45, hspace=0.5, wspace=0.2, legend_loc="upper right",
    col_celltype=col_celltype, col_sample=col_sample)
if len(self.rna[subset_gc & subset_old].obs[col_batch].unique()) > 1:
    raise ValueError("Check subsetting")
key_1 = self.rna[subset_gc & subset_old].obs[col_batch].unique()[0]

# Old Spaceflight SnCs
print(f"\n\n{'=' * 80}\nSpaceflight (Aged)\n{'=' * 80}\n\n")
subset_sf = self.rna.obs[col_condition] == keys[
    col_condition]["key_treatment"]
out_edgr_contrasts_snc_sf = scflow.ax.run_deg_edgr(
    self.rna[subset_sf & subset_old], "Senescent_Cell_Label",
    key_treatment="Senescent", key_control="Non-Senescent",
    log2fc_thresh=0, n_top_vars=24, xlabel_rotation=45,
    hspace=0.5, wspace=0.2, top=0.92, legend_loc="upper right",
    col_celltype=col_celltype, col_sample=col_sample)
if len(self.rna[subset_sf & subset_old].obs[col_batch].unique()) > 1:
    raise ValueError("Check subsetting")
key_2 = self.rna[subset_sf & subset_old].obs[col_batch].unique()[0]

# Compare
res_snc_gc = out_edgr_contrasts_snc_gc[0][out_edgr_contrasts_snc_gc[
    0].adj_p_value < 0.001].sort_values("adj_p_value").set_index("variable")
res_snc_sf = out_edgr_contrasts_snc_sf[0][out_edgr_contrasts_snc_sf[
    0].adj_p_value < 0.001].sort_values("adj_p_value").set_index("variable")
res_snc_grps = pd.concat([
    res_snc_gc, res_snc_sf], keys=[key_1, key_2], names=[col_condition])
res_snc_grps = res_snc_grps[res_snc_grps.abs_log_fc >= 1]
# top_tx_g_snc = res_snc_grps.loc[keys[col_condition][
#     "key_treatment"]].sort_values("abs_log_fc", ascending=False).index
# print(res_snc_grps.unstack(0).replace(np.nan, "")[[
#     "log_fc", "adj_p_value"]].loc[top_tx_g_snc])
# just_sf = res_snc_grps.loc[keys[col_condition][
#     "key_treatment"]].index.difference(res_snc_grps.loc[keys[
#         col_condition]["key_control"]].index)
# just_gc = res_snc_grps.loc[keys[col_condition][
#     "key_control"]].index.difference(res_snc_grps.loc[keys[
#         col_condition]["key_treatment"]].index)
# print(res_snc_grps.loc[:, just_gc, :].sort_values(
#     "abs_log_fc", ascending=False)[["log_fc", "adj_p_value"]], "\n\n")
# res_snc_grps.loc[:, just_sf, :].sort_values(
#     "abs_log_fc", ascending=False)[["log_fc", "adj_p_value"]]
res_snc_grps.unstack(0).replace(np.nan, "")[["log_fc", "adj_p_value"]]

Group DEGs (SnC=Covariate)¶

In [ ]:
out_edgr_contrasts_snc_cov = {}
for a in self.rna.obs[col_age].unique():
    print(f"\n\n{'=' * 80}\nAge = {a}\n{'=' * 80}\n\n")
    out_edgr_contrasts_snc_cov[a] = scflow.ax.run_deg_edgr(
        self.rna[self.rna.obs[col_age] == a], col_condition,
        col_covariate="Senescent_Cell_Label",
        **keys[col_condition], log2fc_thresh=0, n_top_vars=24,
        xlabel_rotation=45, hspace=0.5, wspace=0.2, top=0.85,
        legend_loc="upper right", col_celltype=col_celltype,
        col_sample=col_sample)
    plt.show()

Group DEGs (SnC=Subset)¶

All Groups SnCs¶
In [ ]:
out_edgr_groups_snc = scflow.ax.run_deg_edgr(
    self.rna[(self.rna.obs["Senescent_Cell_Label"] == "Senescent")],
    col_batch, **keys[col_batch], col_sample=col_sample,
    log2fc_thresh=0, n_top_vars=25, col_celltype=col_celltype)
print(list(out_edgr_groups[0].variable[:25]))
out_edgr_batches_snc = out_edgr_groups[0][(
    out_edgr_groups[0].abs_log_fc > 1) & (
        out_edgr_groups[0].adj_p_value < 0.001)].sort_values(
            "adj_p_value", ascending=True)
out_edgr_batches_top = out_edgr_batches.groupby("contrast").apply(
    lambda x: x.sort_values("adj_p_value", ascending=True).iloc[
        :20]).set_index("variable", append=True).reset_index(
            1, drop=True).rename_axis([col_condition, "variable"])
plt.show()
Just Aged SnCs¶
In [ ]:
out_edgr_contrasts_sncto, snc_degs_by_condition_age_ct = {}, {}
thresh_p_c, thresh_lfcabs_c = 0.05, 0.5  # thresholds
subs_old = self.rna.obs[col_age] == keys[col_age]["key_treatment"]
subs_sf = self.rna.obs[col_condition] == keys[col_condition]["key_treatment"]
# subs_ac = (self.rna.obs["Senescent_Cell_Label"] == "Senescent") & (
#     subs_old | subs_sf)
subs_ac = (self.rna.obs["Senescent_Cell_Label"] == "Senescent") & (subs_old)
out_edgr_contrasts_sncto["Overall"] = scflow.ax.run_deg_edgr(
        self.rna[subs_ac], col_condition,
        # col_covariate=col_age,
        **keys[col_condition],
        log2fc_thresh=0, n_top_vars=24,
        legend_loc="upper center", fig_title=f"Overall",
        wspace=0.25, bottom=0.3, hspace=1 if len(x) > 10 else 0.4, top=0.95,
        kws_xticks=dict(fontsize=10, rotation=45 if len(x) > 10 else None),
        col_celltype=col_celltype, col_sample=col_sample)
plt.show()
tmp = out_edgr_contrasts_sncto["Overall"][0]
tmp = tmp[(tmp.adj_p_value < thresh_p_c) & (
    tmp.abs_log_fc >= thresh_lfcabs_c)]  # filter by p & lfc
snc_degs_by_condition_age_ct["Overall"] = list(
    tmp.sort_values("adj_p_value", ascending=True).variable)
for x in self.rna.obs[col_celltype].unique():
    print(x)
    out_edgr_contrasts_sncto[x] = scflow.ax.run_deg_edgr(
        self.rna[(subs_ac) & (self.rna.obs[col_celltype] == x)],
        col_condition,
        # col_covariate=col_age,
        **keys[col_condition],
        log2fc_thresh=0, n_top_vars=24,
        legend_loc="upper center", fig_title=f"Senescent {x}",
        wspace=0.25, bottom=0.3, hspace=1 if len(x) > 10 else 0.4, top=0.95,
        kws_xticks=dict(fontsize=10, rotation=45 if len(x) > 10 else None),
        col_celltype=col_celltype, col_sample=col_sample)
    plt.show()
    tmp = out_edgr_contrasts_sncto[x][0]
    tmp = tmp[(tmp.adj_p_value < thresh_p_c) & (
        tmp.abs_log_fc >= thresh_lfcabs_c)]  # filter by p & lfc
    snc_degs_by_condition_age_ct[x] = list(tmp.sort_values(
            "adj_p_value", ascending=True).variable)
    del tmp
out_edgr_contrasts_snc_all_top = pd.concat([out_edgr_contrasts_sncto[x][
    0].set_index("variable").loc[snc_degs_by_condition_age_ct[
        x]] for x in out_edgr_contrasts_sncto], keys=out_edgr_contrasts_sncto,
                                           names=[col_celltype])
out_edgr_contrasts_snc_all = pd.concat([
    out_edgr_contrasts_sncto[x][0].set_index("variable")
    for x in out_edgr_contrasts_sncto], keys=out_edgr_contrasts_sncto,
                                       names=[col_celltype])
out_edgr_contrasts_snc_all_top

More Specific Contrasts (pyDESeq2)¶

Group¶

In [ ]:
# pdata =  scflow.tl.create_pseudobulk(
#     self.rna, [col_sample, col_condition, col_age],
#     col_celltype, layer="counts", mode="sum")
# design = f"~{col_condition} + {col_age} + {col_condition} * {col_age}"
# # edgr = pt.tl.EdgeR(pdata, design=design)
# pds2 = pt.tl.PyDESeq2(adata=pdata, design=design)
# pds2.fit()
# key_control, key_treatment = [keys[col_condition][k] for k in [
#     "key_control", "key_treatment"]]
# key_control_cov, key_treatment_cov = [keys[col_age][k] for k in [
#     "key_control", "key_treatment"]]
# sf_old = {col_condition: key_treatment, col_age: key_treatment_cov}
# sf_yng = {col_condition: key_treatment, col_age: key_control_cov}
# gc_old = {col_condition: key_control, col_age: key_treatment_cov}
# gc_yng = {col_condition: key_control, col_age: key_control_cov}

# # Spaceflight-Specific Age DEGs
# spaceflight_specfic_age_degs = (pds2.cond(**sf_old) - pds2.cond(
#     **sf_yng)) - (pds2.cond(**gc_old) - pds2.cond(**gc_yng))
# interaction_res_df = pds2.test_contrasts(spaceflight_specfic_age_degs)
# pds2.plot_volcano(interaction_res_df, log2fc_thresh=0)

# # Age-Specific Spaceflight DEGs
# age_specfic_sf_degs = (pds2.cond(**sf_old) - pds2.cond(**gc_old)) - (
#     pds2.cond(**sf_yng) - pds2.cond(**gc_yng))
# interaction_res_df2 = pds2.test_contrasts(age_specfic_sf_degs)
# pds2.plot_volcano(interaction_res_df2, log2fc_thresh=0)

# # Old vs. Young Spaceflight
# age_sf_ix = pds2.cond(**sf_old) - pds2.cond(**sf_yng)
# interaction_res_df3 = pds2.test_contrasts(age_sf_ix)
# pds2.plot_volcano(interaction_res_df3, log2fc_thresh=0)

# # Old vs. Young GC
# age_gc_ix = pds2.cond(**gc_old) - pds2.cond(**gc_yng)
# interaction_res_df4 = pds2.test_contrasts(age_gc_ix)
# pds2.plot_volcano(interaction_res_df4, log2fc_thresh=0)

# # SF vs. GC Old
# cond_old_ix = pds2.cond(**sf_old) - pds2.cond(**gc_old)
# interaction_res_df5 = pds2.test_contrasts(cond_old_ix)
# pds2.plot_volcano(interaction_res_df5, log2fc_thresh=0)

# # SF vs. GC Young
# cond_yng_ix = pds2.cond(**sf_yng) - pds2.cond(**gc_yng)
# interaction_res_df6 = pds2.test_contrasts(cond_yng_ix)
# pds2.plot_volcano(interaction_res_df6, log2fc_thresh=0)

# # Compare
# thresh_lfc, thresh_p = 1, 0.001
# sf_deg_res_df_old = interaction_res_df5[(
#     interaction_res_df5.adj_p_value < thresh_p) & (
#         interaction_res_df5.log_fc.abs() >= thresh_lfc)].set_index(
#             "variable")
# sf_deg_res_df_yng = interaction_res_df6[(
#     interaction_res_df6.adj_p_value < thresh_p) & (
#         interaction_res_df6.log_fc.abs() >= thresh_lfc)].set_index(
#             "variable")
# sf_deg_res = pd.concat([sf_deg_res_df_old, sf_deg_res_df_yng],
#                        keys=["Old", "Young"], names=["Age Group"])
# sf_deg_res.loc[:, "log_fc_abs"] = sf_deg_res.log_fc.abs()
# sf_deg_res = sf_deg_res.sort_values("log_fc_abs", ascending=False)[[
#     "log_fc", "adj_p_value"]].unstack(0)
# print("SF DEGs in Both Young & Old: ", sf_deg_res.dropna().index.values)
# print("\n\nSF DEGs in Just Young", list(sf_deg_res_df_yng.index.difference(
#     sf_deg_res_df_old.index)), "\n\n")
# print("SF DEGs in Just Old", list(sf_deg_res_df_old.index.difference(
#     sf_deg_res_df_yng.index)), "\n\n")
# sf_deg_res.replace(np.nan, "")

# # Marker Set Overlap
# print("Both: ", marker_gene_sets.apply(
#     lambda i: set(sf_deg_res.dropna().index).intersection(set(i))).apply(
#         lambda x: x if len(x) > 0 else np.nan).dropna(), "\n\n")
# print("Young: ", marker_gene_sets.apply(
#     lambda i: sf_deg_res_df_yng.index.difference(
#         sf_deg_res_df_old.index).intersection(set(i))).apply(
#         lambda x: x if len(x) > 0 else np.nan).dropna(), "\n\n")
# print("Old: ", marker_gene_sets.apply(
#     lambda i: sf_deg_res_df_old.index.difference(
#         sf_deg_res_df_yng.index).intersection(set(i))).apply(
#         lambda x: x if len(x) > 0 else np.nan).dropna(), "\n\n")

SnCs¶

Old¶
In [ ]:
# Setup
design = (f"~{col_condition} + Senescent_Cell_Label + "
          f"{col_condition} * Senescent_Cell_Label")
pdata2 =  scflow.tl.create_pseudobulk(
    self.rna[self.rna.obs[col_age] == keys[col_age]["key_treatment"]], [
        col_sample, col_condition, "Senescent_Cell_Label"],
    "Senescent_Cell_Label_by_Type", layer="counts", mode="sum")
pds2_snc_old = pt.tl.PyDESeq2(adata=pdata2, design=design)
pds2_snc_old.fit()
key_control, key_treatment = [keys[col_condition][k] for k in [
    "key_control", "key_treatment"]]
key_control_cov, key_treatment_cov = "Non-Senescent", "Senescent"
sf_sc = {col_condition: key_treatment,
         "Senescent_Cell_Label": key_treatment_cov}
sf_ns = {col_condition: key_treatment,
         "Senescent_Cell_Label": key_control_cov}
gc_snc = {col_condition: key_control,
          "Senescent_Cell_Label": key_treatment_cov}
gc_ns = {col_condition: key_control, "Senescent_Cell_Label": key_control_cov}

# SnC DEGs
res_df_snc = pds2_snc_old.test_contrasts(pds2_snc_old.contrast(
    column="Senescent_Cell_Label", baseline=key_control_cov,
    group_to_compare=key_treatment_cov))
print(res_df_snc[res_df_snc.adj_p_value < 0.001].head(10))
pds2_snc_old.plot_volcano(res_df_snc, log2fc_thresh=0)

# Spaceflight-Specific SnC DEGs
spaceflight_specfic_snc_degs = (pds2_snc_old.cond(
    **sf_sc) - pds2_snc_old.cond(**sf_ns)) - (
        pds2_snc_old.cond(**gc_snc) - pds2_snc_old.cond(**gc_ns))
interaction_res_df_snc_sf = pds2_snc_old.test_contrasts(
    spaceflight_specfic_snc_degs)
print(interaction_res_df_snc_sf[
    interaction_res_df_snc_sf.adj_p_value < 0.001].head(10))
pds2_snc_old.plot_volcano(interaction_res_df_snc_sf, log2fc_thresh=0)
Young¶
In [ ]:
# Setup
design = (f"~{col_condition} + Senescent_Cell_Label + "
          f"{col_condition} * Senescent_Cell_Label")
pdata2 =  scflow.tl.create_pseudobulk(
    self.rna[self.rna.obs[col_age] == keys[col_age]["key_treatment"]], [
        col_sample, col_condition, "Senescent_Cell_Label"],
    "Senescent_Cell_Label_by_Type", layer="counts", mode="sum")
pds2_snc_yng = pt.tl.PyDESeq2(adata=pdata2, design=design)
pds2_snc_yng.fit()
key_control, key_treatment = [keys[col_condition][k] for k in [
    "key_control", "key_treatment"]]
key_control_cov, key_treatment_cov = "Non-Senescent", "Senescent"
sf_sc = {col_condition: key_treatment,
         "Senescent_Cell_Label": key_treatment_cov}
sf_ns = {col_condition: key_treatment,
         "Senescent_Cell_Label": key_control_cov}
gc_snc = {col_condition: key_control,
          "Senescent_Cell_Label": key_treatment_cov}
gc_ns = {col_condition: key_control, "Senescent_Cell_Label": key_control_cov}

# SnC DEGs
res_df_snc = pds2_snc_yng.test_contrasts(pds2_snc_yng.contrast(
    column="Senescent_Cell_Label", baseline=key_control_cov,
    group_to_compare=key_treatment_cov))
print(res_df_snc[res_df_snc.adj_p_value < 0.001].head(10))
pds2_snc_yng.plot_volcano(res_df_snc, log2fc_thresh=0)

# Spaceflight-Specific SnC DEGs
spaceflight_specfic_snc_degs = (pds2_snc_yng.cond(
    **sf_sc) - pds2_snc_yng.cond(**sf_ns)) - (
        pds2_snc_yng.cond(**gc_snc) - pds2_snc_yng.cond(**gc_ns))
interaction_res_df_snc_sf = pds2_snc_yng.test_contrasts(
    spaceflight_specfic_snc_degs)
pds2_snc_yng.plot_volcano(interaction_res_df_snc_sf, log2fc_thresh=0)

SnCs (More Permissive Threshold)¶

In [ ]:
# Compare Less & More Permissive Thresholds
print("Less & More Permissive SnC Threshold: ", self.rna.obs[[
    "Senescent_Cell_Label", f"Senescent_Cell_Label_{use_metric}_{p_h}"
    ]].value_counts())
sen_lab = f"Senescent_Cell_Label_{use_metric}_{p_h}"

# Setup
design = (f"~{col_condition} + {sen_lab} + "
          f"{col_condition} * {sen_lab}")
pdata2_3 =  scflow.tl.create_pseudobulk(
    self.rna[self.rna.obs[col_age] == keys[col_age]["key_treatment"]], [
        col_sample, col_condition, sen_lab],
    col_celltype, layer="counts", mode="sum")
pds2_snc_old_3 = pt.tl.PyDESeq2(adata=pdata2_3, design=design)
pds2_snc_old_3.fit()
key_control, key_treatment = [keys[col_condition][k] for k in [
    "key_control", "key_treatment"]]
key_control_cov, key_treatment_cov = "Non-Senescent", "Senescent"
sf_sc = {col_condition: key_treatment, sen_lab: key_treatment_cov}
sf_ns = {col_condition: key_treatment, sen_lab: key_control_cov}
gc_snc = {col_condition: key_control, sen_lab: key_treatment_cov}
gc_ns = {col_condition: key_control, sen_lab: key_control_cov}

# SnC DEGs
res_df_snc_3 = pds2_snc_old_3.test_contrasts(pds2_snc_old_3.contrast(
    column=sen_lab, baseline=key_control_cov,
    group_to_compare=key_treatment_cov))
print(res_df_snc_3[res_df_snc_3.adj_p_value < 0.001].head(10))
pds2_snc_old_3.plot_volcano(res_df_snc_3, log2fc_thresh=0)

# Spaceflight-Specific SnC DEGs
spaceflight_specfic_snc_degs_3 = (pds2_snc_old_3.cond(
    **sf_sc) - pds2_snc_old_3.cond(**sf_ns)) - (
        pds2_snc_old_3.cond(**gc_snc) - pds2_snc_old_3.cond(**gc_ns))
interaction_res_df_snc_sf_3 = pds2_snc_old_3.test_contrasts(
    spaceflight_specfic_snc_degs_3)
pds2_snc_old_3.plot_volcano(interaction_res_df_snc_sf_3, log2fc_thresh=0)

MAST¶

In [ ]:
# %%R
# find_de_MAST_RE <- function(adata_, formula){
#     # create a MAST object
#     sca <- SceToSingleCellAssay(adata_, class="SingleCellAssay")
#     print("Dimensions before subsetting:")
#     print(dim(sca))
#     print("")
#     # keep genes that are expressed in more than 10% of all cells
#     sca <- sca[freq(sca) > 0.1,]
#     print("Dimensions after subsetting:")
#     print(dim(sca), "\n")
#     cdr2 <- colSums(assay(sca) > 0)
#     colData(sca)$ngeneson <- scale(cdr2)
#     # store the columns that we are interested in as factors
#     label <- factor(colData(sca)$label)
#     # set the reference level
#     label <- relevel(label,"ctrl")
#     colData(sca)$label <- label
#     celltype <- factor(colData(sca)$cell_type)
#     colData(sca)$celltype <- celltype
#     # same for donors (which we need to model random effects)
#     replicate <- factor(colData(sca)$replicate)
#     colData(sca)$replicate <- replicate
#     # create a group per condition-celltype combination
#     colData(sca)$group <- paste0(colData(
#         adata_)$label, ".", colData(adata_)$cell_type)
#     colData(sca)$group <- factor(colData(sca)$group)
#     # define and fit the model
#     zlmCond <- zlm(formula=formula,
#                    sca=sca,
#                    method="glmer",
#                    ebayes=F,
#                    strictConvergence=F,
#                    fitArgsD=list(nAGQ = 0)) # to speed up calculations
#     # perform likelihood-ratio test for the condition
#     summaryCond <- summary(zlmCond, doLRT="groupstim.CD14_Monocytes")
#     # get the table with log-fold changes and p-values
#     summaryDt <- summaryCond$datatable
#     return(summaryDt)
# }

SnC GEX Profiles¶

Pathway Analysis¶

In [ ]:
names = gp.get_library_name()
# perts_geo = ["Aging", "Drug", "Disease"]
perts_geo = ["Aging", "Disease"]
other_sets = ["GTEx_Aging_Signatures_2021", f"HDSigDB_{species}_2021",
              "MSigDB_Hallmark_2020",  # "DGIdb_Drug_Targets_2024",
              "MSigDB_Oncogenic_Signatures", "OMIM_Disease",
              # "Reimport pdb;actome_Pathways_2024", "Reactome_2022",
              f"WikiPathways_2024_{species}", f"WikiPathways_2019_{species}"]
other_sets += [i for i in names if "GO_Biological_Process" in i]
gene_sets = dict(zip(["up", "down"], [[
    f"{u}_Perturbations_from_GEO_{i}" for u in perts_geo] + [
        f"Disease_Signatures_from_GEO_{i}_2014"] + other_sets
    for i in ["up", "down"]]))


def fx_replace_string(string):
    """Make short version of pathway terms."""
    string = re.sub("aging:([0-9]+)", "aging", re.sub(
        "([0-9]+) months v ([0-9]+) mo(nths)?", "\\1 v \\2 mo.", re.sub(
            "SRP[0-9]+ ", "", re.sub("GSE[0-9]+ ", "", string))))
    string = re.sub(".*.xlsx.", "", re.sub(
        ".*Supplementary Data ..", "", re.sub(
            "PMID([0-9])+", "", re.sub("([0-9]+) years v ([0-9]+) years",
                                       "\\1 v \\2 yrs.", string))))
    string = re.sub("Expression Of ", "", re.sub(".*.xls", "", re.sub(
        ".*.XLSX", "", re.sub(
            ".*Supplementary Table [0-9]+[-]?", "", string))))
    return string

Endrichr¶

In [ ]:
out_pathway_snc_edgr_contrasts = scflow.ax.run_enrichr(
    out_edgr_contrasts_snc_all_top, col_grouping=["Comparison", col_celltype],
    gene_sets=gene_sets, fx_replace_string=fx_replace_string, title="Overall")

SnC vs. Not¶

In [ ]:
# res_dc_ulm = scflow.ax.run_decoupler_ulm(
#         self.rna[self.rna.obs["Senescent_Cell_Label"] == "Senescent"],
#         # "Senescent_Cell_Label_by_Type",
#         # "Senescent_Cell_Label",
#         col_condition, col_condition="Senescent_Cell_Label_by_Type",
#         species=species, resource="hallmark",
#         top=0.95, hspace=1, wspace=0.5, figsize=(15, 10))

Pathway Set = Progeny¶

In [ ]:
res_dc_ulm = scflow.ax.run_decoupler_ulm(
        self.rna[self.rna.obs["Senescent_Cell_Label"] == "Senescent"],
        col_condition, col_condition="Senescent_Cell_Label_by_Type",
        species=species, resource="progeny",
        hspace=0.5, wspace=0.5, top=0.95, figsize=(15, 15))
res_dc_ulm_scores = pd.concat([res_dc_ulm[0][x][1].set_index(
    "group").rename_axis(col_condition).set_index(
        "name", append=True) for x in res_dc_ulm[0]],
                              keys=res_dc_ulm[0], names=[col_celltype])
res_dc_ulm_pathways = pd.concat([pd.Series(res_dc_ulm[0][x][2])
                                 for x in res_dc_ulm[0]], keys=res_dc_ulm[0])
print(res_dc_ulm_pathways)
res_dc_ulm_scores
reduce expected at least 2 arguments, got 1
SnC OPC              Ground Control       [Androgen, Estrogen, VEGF]
                     Space Flight                 [NFkB, PI3K, TNFa]
SnC Neuron           Ground Control       [Estrogen, Androgen, NFkB]
                     Space Flight                 [PI3K, VEGF, EGFR]
SnC Oligodendrocyte  Ground Control         [Estrogen, Hypoxia, WNT]
                     Space Flight                [PI3K, EGFR, Trail]
SnC Endothelial      Ground Control           [TGFb, VEGF, Androgen]
                     Space Flight            [Trail, Estrogen, EGFR]
SnC Microglial       Ground Control    [Estrogen, Hypoxia, Androgen]
                     Space Flight            [JAK-STAT, Trail, TNFa]
SnC Astrocyte        Ground Control       [Estrogen, MAPK, JAK-STAT]
                     Space Flight              [PI3K, VEGF, Hypoxia]
dtype: object
Out[ ]:
reference stat meanchange pval padj
annotation_scanvi_collapsed Condition name
SnC OPC Ground Control Androgen rest 2.757708 0.724846 8.382574e-03 1.173560e-01
Estrogen rest 2.081309 0.557417 4.317564e-02 1.511148e-01
VEGF rest 1.899823 0.569651 6.389319e-02 1.676413e-01
MAPK rest 0.605538 0.177445 5.480702e-01 6.244029e-01
JAK-STAT rest 0.136164 0.043412 8.922867e-01 8.922867e-01
Space Flight NFkB rest 2.248224 0.778948 3.000980e-02 1.511148e-01
PI3K rest 2.095528 0.545715 4.166130e-02 1.511148e-01
TNFa rest 1.844120 0.579368 7.184625e-02 1.676413e-01
EGFR rest 1.479733 0.627585 1.457831e-01 2.915662e-01
Trail rest 1.272377 0.368791 2.098306e-01 3.672036e-01
TGFb rest 1.078802 0.391425 2.866111e-01 4.458395e-01
WNT rest 0.931677 0.224857 3.565740e-01 4.992036e-01
p53 rest 0.724510 0.293513 4.724453e-01 6.012941e-01
Hypoxia rest 0.558034 0.205651 5.798027e-01 6.244029e-01
SnC Neuron Ground Control Estrogen rest 9.500359 0.482193 6.141583e-21 8.598216e-20
Androgen rest 7.283937 0.341144 4.741372e-13 1.659480e-12
NFkB rest 5.826446 0.328417 6.703352e-09 1.876939e-08
MAPK rest 5.476003 0.360809 4.954974e-08 1.156161e-07
JAK-STAT rest 3.427728 0.188864 6.223002e-04 1.244600e-03
TNFa rest 0.905685 0.049524 3.652234e-01 4.260939e-01
Trail rest 0.356124 0.013530 7.217877e-01 7.773099e-01
WNT rest 0.032851 0.001281 9.737973e-01 9.737973e-01
Space Flight PI3K rest 6.765508 0.479925 2.158089e-11 1.510663e-10
VEGF rest 6.238393 0.465892 6.091033e-10 2.842482e-09
EGFR rest 2.727422 0.276192 6.475309e-03 1.133179e-02
Hypoxia rest 1.675481 0.124868 9.409898e-02 1.463762e-01
TGFb rest 1.351366 0.101788 1.768255e-01 2.475557e-01
p53 rest 0.896480 0.073842 3.701778e-01 4.711353e-01
SnC Oligodendrocyte Ground Control Estrogen rest 3.334559 0.414669 1.005425e-03 1.407595e-02
Hypoxia rest 2.820404 0.404899 5.249221e-03 3.674455e-02
WNT rest 1.900624 0.212298 5.868023e-02 2.033951e-01
MAPK rest 1.777636 0.269305 7.692159e-02 2.033951e-01
TGFb rest 1.718262 0.195343 8.716934e-02 2.033951e-01
NFkB rest 0.808573 0.100958 4.196512e-01 8.032411e-01
VEGF rest 0.458603 0.058390 6.469758e-01 8.032411e-01
Space Flight PI3K rest 1.959169 0.238152 5.119465e-02 1.515907e-01
EGFR rest 0.761928 0.119689 4.468132e-01 7.819231e-01
Trail rest 0.581383 0.057859 5.614986e-01 7.880744e-01
p53 rest 0.464857 0.059114 6.424335e-01 7.880744e-01
JAK-STAT rest 0.303798 0.034887 7.615324e-01 7.880744e-01
Androgen rest 0.296035 0.040314 7.674461e-01 7.880744e-01
TNFa rest 0.269097 0.032517 7.880744e-01 7.880744e-01
SnC Endothelial Ground Control TGFb rest 1.400034 0.761347 1.779404e-01 3.417916e-01
VEGF rest 0.978723 0.581423 3.453250e-01 5.371722e-01
Androgen rest 0.786702 0.185250 4.404327e-01 6.166058e-01
PI3K rest 0.627001 0.470541 5.371859e-01 6.836912e-01
Hypoxia rest 0.335466 0.130014 7.404797e-01 7.974397e-01
TNFa rest 0.016855 0.009220 9.867047e-01 9.867047e-01
Space Flight Trail rest 3.251158 2.080820 3.940980e-02 5.517372e-01
Estrogen rest 1.942157 1.748921 1.574474e-01 9.423082e-01
EGFR rest 1.119047 1.727110 3.365294e-01 9.423082e-01
WNT rest 1.008216 0.614008 3.934548e-01 9.423082e-01
MAPK rest 0.865796 1.573822 4.555649e-01 9.423082e-01
p53 rest 0.754090 0.666123 5.286061e-01 9.423082e-01
NFkB rest 0.669465 0.632085 5.425169e-01 9.423082e-01
JAK-STAT rest 0.178556 0.141105 8.690182e-01 9.423082e-01
SnC Microglial Ground Control Estrogen rest 2.199313 0.604043 3.200895e-02 4.481254e-01
Hypoxia rest 1.633230 0.419244 1.082607e-01 5.620789e-01
Androgen rest 1.577148 0.417044 1.204455e-01 5.620789e-01
TGFb rest 0.956054 0.250233 3.431805e-01 7.537423e-01
MAPK rest 0.890919 0.285940 3.768712e-01 7.537423e-01
VEGF rest 0.320028 0.068197 7.501809e-01 9.437506e-01
Space Flight JAK-STAT rest 1.393819 0.313861 1.680881e-01 5.883084e-01
Trail rest 1.119993 0.245419 2.667810e-01 6.766235e-01
TNFa rest 0.535728 0.138733 5.941373e-01 9.390585e-01
PI3K rest 0.279185 0.075402 7.809866e-01 9.390585e-01
p53 rest 0.265101 0.066740 7.917737e-01 9.390585e-01
WNT rest 0.228122 0.061728 8.202632e-01 9.390585e-01
NFkB rest 0.126241 0.031720 8.999499e-01 9.390585e-01
EGFR rest 0.076769 0.023985 9.390585e-01 9.390585e-01
SnC Astrocyte Ground Control Estrogen rest 1.837555 0.285077 6.884086e-02 2.729383e-01
MAPK rest 1.428339 0.303562 1.559084e-01 4.357931e-01
JAK-STAT rest 0.018456 0.002780 9.853065e-01 9.853065e-01
Space Flight PI3K rest 2.631447 0.415732 9.604981e-03 1.344697e-01
VEGF rest 2.258330 0.426227 2.570189e-02 1.799132e-01
Hypoxia rest 1.822952 0.373012 7.076687e-02 2.476841e-01
Androgen rest 1.361468 0.281741 1.758971e-01 4.104266e-01
EGFR rest 1.065640 0.216080 2.888035e-01 5.776071e-01
p53 rest 0.839553 0.192130 4.028111e-01 7.049193e-01
TGFb rest 0.654916 0.155232 5.137672e-01 7.991934e-01
Trail rest 0.342109 0.050880 7.328643e-01 9.399009e-01
WNT rest 0.316784 0.047958 7.519635e-01 9.399009e-01
NFkB rest 0.246608 0.044382 8.056294e-01 9.399009e-01
TNFa rest 0.049402 0.008985 9.606799e-01 9.849361e-01
No description has been provided for this image

Pathway Set = Hallmark¶

In [177]:
res_dc_ulm_hm = scflow.ax.run_decoupler_ulm(
        self.rna[self.rna.obs["Senescent_Cell_Label"] == "Senescent"],
        col_condition, col_condition="Senescent_Cell_Label_by_Type",
        species=species, resource="hallmark",
        hspace=0.5, top=0.95, figsize=(15, 15))
res_dc_ulm_hm_scores = pd.concat([res_dc_ulm_hm[0][x][1].set_index(
    "group").rename_axis(col_condition).set_index(
        "name", append=True) for x in res_dc_ulm_hm[0]],
                                 keys=res_dc_ulm_hm[0], names=[col_celltype])
res_dc_ulm_hm_scores
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Out[177]:
reference stat meanchange pval padj
annotation_scanvi_collapsed Condition name
SnC OPC Ground Control UNFOLDED_PROTEIN_RESPONSE rest 3.148356 0.573193 3.024018e-03 2.520015e-02
APICAL_SURFACE rest 1.860512 0.476689 6.923833e-02 2.663013e-01
HEME_METABOLISM rest 1.675026 0.389181 1.007165e-01 3.043063e-01
ESTROGEN_RESPONSE_EARLY rest 1.603981 0.395632 1.156364e-01 3.043063e-01
BILE_ACID_METABOLISM rest 1.409833 0.305282 1.653179e-01 3.757224e-01
PROTEIN_SECRETION rest 1.291372 0.465757 2.046302e-01 3.818708e-01
ESTROGEN_RESPONSE_LATE rest 1.000520 0.274508 3.225932e-01 5.376553e-01
MITOTIC_SPINDLE rest 0.843344 0.305709 4.034980e-01 6.304656e-01
DNA_REPAIR rest 0.779627 0.166768 4.396200e-01 6.554873e-01
ANDROGEN_RESPONSE rest 0.747198 0.218936 4.588411e-01 6.554873e-01
MYC_TARGETS_V2 rest 0.658130 0.143188 5.137388e-01 7.135262e-01
PEROXISOME rest 0.619365 0.167230 5.387650e-01 7.280608e-01
WNT_BETA_CATENIN_SIGNALING rest 0.227567 0.057822 8.209931e-01 9.331232e-01
APOPTOSIS rest 0.203285 0.045779 8.398109e-01 9.331232e-01
SPERMATOGENESIS rest 0.151917 0.043679 8.799167e-01 9.360816e-01
INTERFERON_GAMMA_RESPONSE rest 0.060790 0.012859 9.517954e-01 9.914535e-01
Space Flight COAGULATION rest 4.250807 1.224458 1.137765e-04 5.688826e-03
ADIPOGENESIS rest 3.642291 0.960716 6.879389e-04 1.719847e-02
APICAL_JUNCTION rest 3.270742 1.186918 2.297720e-03 2.520015e-02
MYOGENESIS rest 3.192599 0.861542 2.743790e-03 2.520015e-02
OXIDATIVE_PHOSPHORYLATION rest 3.166107 1.168319 2.837315e-03 2.520015e-02
TNFA_SIGNALING_VIA_NFKB rest 2.968633 0.852557 4.833602e-03 3.452573e-02
INFLAMMATORY_RESPONSE rest 2.863359 0.876734 6.539631e-03 4.087270e-02
KRAS_SIGNALING_DN rest 2.723633 0.883038 9.217372e-03 4.762634e-02
EPITHELIAL_MESENCHYMAL_TRANSITION rest 2.748511 1.207515 9.525267e-03 4.762634e-02
COMPLEMENT rest 2.267542 0.770072 2.883656e-02 1.310753e-01
MTORC1_SIGNALING rest 1.991202 0.559144 5.243595e-02 2.184831e-01
MYC_TARGETS_V1 rest 1.757284 0.631625 8.645473e-02 3.043063e-01
HYPOXIA rest 1.680201 0.463292 1.001070e-01 3.043063e-01
NOTCH_SIGNALING rest 1.659145 0.530187 1.039100e-01 3.043063e-01
CHOLESTEROL_HOMEOSTASIS rest 1.631818 0.439760 1.104984e-01 3.043063e-01
ANGIOGENESIS rest 1.479370 0.677662 1.471858e-01 3.679644e-01
UV_RESPONSE_DN rest 1.430943 0.449290 1.593721e-01 3.757224e-01
KRAS_SIGNALING_UP rest 1.362844 0.452965 1.796567e-01 3.818708e-01
TGF_BETA_SIGNALING rest 1.321252 0.436720 1.931622e-01 3.818708e-01
IL2_STAT5_SIGNALING rest 1.308489 0.352776 1.973604e-01 3.818708e-01
FATTY_ACID_METABOLISM rest 1.282750 0.326785 2.062102e-01 3.818708e-01
REACTIVE_OXYGEN_SPECIES_PATHWAY rest 1.199875 0.331483 2.367610e-01 4.227874e-01
PANCREAS_BETA_CELLS rest 1.059714 0.338602 2.949731e-01 5.085744e-01
GLYCOLYSIS rest 0.915958 0.270276 3.645321e-01 5.879550e-01
G2M_CHECKPOINT rest 0.768646 0.256997 4.463063e-01 6.554873e-01
UV_RESPONSE_UP rest 0.545786 0.132503 5.879931e-01 7.541098e-01
HEDGEHOG_SIGNALING rest 0.545731 0.170815 5.882056e-01 7.541098e-01
XENOBIOTIC_METABOLISM rest 0.412141 0.116982 6.822219e-01 8.351453e-01
E2F_TARGETS rest 0.408490 0.120569 6.848192e-01 8.351453e-01
P53_PATHWAY rest 0.317519 0.074457 7.523022e-01 8.955978e-01
ALLOGRAFT_REJECTION rest 0.215310 0.049521 8.305324e-01 9.331232e-01
INTERFERON_ALPHA_RESPONSE rest 0.179327 0.052068 8.584850e-01 9.331359e-01
IL6_JAK_STAT3_SIGNALING rest 0.032245 0.007541 9.744633e-01 9.943503e-01
PI3K_AKT_MTOR_SIGNALING rest 0.005435 0.001441 9.956891e-01 9.956891e-01
SnC Neuron Ground Control BILE_ACID_METABOLISM rest 2.184045 0.083742 2.908369e-02 3.462344e-02
INTERFERON_GAMMA_RESPONSE rest 1.576291 0.069536 1.151292e-01 1.308287e-01
MYC_TARGETS_V2 rest 1.208428 0.038149 2.270407e-01 2.522675e-01
UV_RESPONSE_DN rest 0.710002 0.055284 4.777931e-01 5.082905e-01
IL6_JAK_STAT3_SIGNALING rest 0.349561 0.012415 7.267074e-01 7.569868e-01
Space Flight OXIDATIVE_PHOSPHORYLATION rest 24.867264 3.164509 3.803166e-106 1.901583e-104
ADIPOGENESIS rest 19.737703 1.304684 6.612366e-75 1.653092e-73
MYC_TARGETS_V1 rest 18.769672 1.695644 9.097074e-68 1.516179e-66
MTORC1_SIGNALING rest 18.158076 1.227961 5.942483e-65 7.428103e-64
UV_RESPONSE_UP rest 17.160545 1.131422 9.721386e-59 9.721386e-58
FATTY_ACID_METABOLISM rest 15.305557 0.881125 2.710785e-48 2.258987e-47
GLYCOLYSIS rest 15.228719 0.891421 5.308639e-48 3.791885e-47
COMPLEMENT rest 14.015157 0.755307 1.541680e-41 9.635502e-41
REACTIVE_OXYGEN_SPECIES_PATHWAY rest 12.728494 0.695763 7.303302e-35 4.057390e-34
APOPTOSIS rest 12.638808 0.710934 1.770230e-34 8.851151e-34
HYPOXIA rest 12.450656 0.718272 1.394905e-33 6.340479e-33
ESTROGEN_RESPONSE_LATE rest 11.585392 0.618636 1.518012e-29 6.325051e-29
MYOGENESIS rest 11.301750 0.694388 2.917710e-28 1.122196e-27
UNFOLDED_PROTEIN_RESPONSE rest 9.987212 0.547767 1.220594e-22 4.359265e-22
CHOLESTEROL_HOMEOSTASIS rest 9.915220 0.524105 2.416493e-22 8.054975e-22
PI3K_AKT_MTOR_SIGNALING rest 9.878976 0.642550 3.331014e-22 1.040942e-21
XENOBIOTIC_METABOLISM rest 9.574982 0.513808 6.020249e-21 1.770661e-20
PROTEIN_SECRETION rest 9.154706 0.722858 2.161096e-19 6.003044e-19
P53_PATHWAY rest 8.333394 0.437984 2.118340e-16 5.574580e-16
KRAS_SIGNALING_UP rest 8.130886 0.444441 1.021171e-15 2.552926e-15
PEROXISOME rest 6.991083 0.320431 4.450749e-12 1.059702e-11
HEDGEHOG_SIGNALING rest 6.980738 0.481842 4.766437e-12 1.083281e-11
TGF_BETA_SIGNALING rest 6.565013 0.464674 7.646655e-11 1.662316e-10
ALLOGRAFT_REJECTION rest 6.210970 0.321179 7.184748e-10 1.496823e-09
SPERMATOGENESIS rest 5.539049 0.360728 3.705268e-08 7.410536e-08
APICAL_JUNCTION rest 5.319314 0.350762 1.233314e-07 2.371757e-07
DNA_REPAIR rest 4.891647 0.238813 1.135231e-06 2.102280e-06
COAGULATION rest 4.879114 0.289533 1.224318e-06 2.186282e-06
APICAL_SURFACE rest 4.838355 0.287991 1.472595e-06 2.538957e-06
EPITHELIAL_MESENCHYMAL_TRANSITION rest 4.697648 0.284127 2.925924e-06 4.876540e-06
ANGIOGENESIS rest 4.368204 0.260928 1.356854e-05 2.188474e-05
PANCREAS_BETA_CELLS rest 4.267481 0.285456 2.126539e-05 3.322718e-05
G2M_CHECKPOINT rest 4.095392 0.268163 4.489328e-05 6.802012e-05
TNFA_SIGNALING_VIA_NFKB rest 3.894946 0.247126 1.039087e-04 1.528069e-04
ANDROGEN_RESPONSE rest 3.809841 0.205880 1.458522e-04 2.083603e-04
MITOTIC_SPINDLE rest 3.534682 0.299265 4.234399e-04 5.881110e-04
E2F_TARGETS rest 3.492490 0.178649 4.959027e-04 6.529159e-04
HEME_METABOLISM rest 3.492007 0.193231 4.962161e-04 6.529159e-04
IL2_STAT5_SIGNALING rest 3.161853 0.174202 1.606175e-03 2.059199e-03
INFLAMMATORY_RESPONSE rest 2.564235 0.147879 1.045640e-02 1.307050e-02
NOTCH_SIGNALING rest 2.070161 0.104380 3.864398e-02 4.712681e-02
ESTROGEN_RESPONSE_EARLY rest 1.693146 0.092251 9.067799e-02 1.054395e-01
KRAS_SIGNALING_DN rest 0.618357 0.042102 5.364528e-01 5.831009e-01
WNT_BETA_CATENIN_SIGNALING rest 0.073239 0.003353 9.416277e-01 9.419449e-01
INTERFERON_ALPHA_RESPONSE rest 0.072841 0.003374 9.419449e-01 9.419449e-01
SnC Oligodendrocyte Ground Control ESTROGEN_RESPONSE_EARLY rest 2.090452 0.247138 3.775489e-02 1.348389e-01
TGF_BETA_SIGNALING rest 1.542515 0.261775 1.244371e-01 2.592440e-01
UV_RESPONSE_DN rest 1.509263 0.233542 1.326806e-01 2.653612e-01
TNFA_SIGNALING_VIA_NFKB rest 1.381708 0.139286 1.684759e-01 3.119924e-01
MITOTIC_SPINDLE rest 1.306547 0.218913 1.927452e-01 3.295562e-01
IL6_JAK_STAT3_SIGNALING rest 1.291977 0.150724 1.977337e-01 3.295562e-01
HEDGEHOG_SIGNALING rest 0.781868 0.108513 4.351406e-01 5.578725e-01
BILE_ACID_METABOLISM rest 0.598056 0.070221 5.504251e-01 6.712501e-01
NOTCH_SIGNALING rest 0.385267 0.049330 7.004224e-01 7.782471e-01
ALLOGRAFT_REJECTION rest 0.321177 0.045313 7.483883e-01 7.961578e-01
INTERFERON_GAMMA_RESPONSE rest 0.261029 0.032342 7.943190e-01 8.252044e-01
KRAS_SIGNALING_UP rest 0.242397 0.034709 8.087003e-01 8.252044e-01
Space Flight OXIDATIVE_PHOSPHORYLATION rest 10.621847 1.614291 1.290951e-21 6.454754e-20
ADIPOGENESIS rest 6.240164 0.830911 1.901992e-09 4.754981e-08
MTORC1_SIGNALING rest 5.839303 0.689714 1.627953e-08 2.713255e-07
MYC_TARGETS_V1 rest 5.781524 0.733480 2.202246e-08 2.752807e-07
CHOLESTEROL_HOMEOSTASIS rest 4.715715 0.631090 3.976415e-06 3.976415e-05
XENOBIOTIC_METABOLISM rest 4.594047 0.535270 6.877921e-06 5.731601e-05
FATTY_ACID_METABOLISM rest 4.108890 0.473116 5.434216e-05 3.881583e-04
COAGULATION rest 4.018363 0.507803 7.727186e-05 4.829491e-04
REACTIVE_OXYGEN_SPECIES_PATHWAY rest 3.815481 0.416689 1.715913e-04 9.532849e-04
PEROXISOME rest 3.487262 0.369153 5.796031e-04 2.660737e-03
MYOGENESIS rest 3.482957 0.418157 5.853622e-04 2.660737e-03
ESTROGEN_RESPONSE_LATE rest 3.013350 0.337196 2.845120e-03 1.185467e-02
UV_RESPONSE_UP rest 2.512959 0.297640 1.261915e-02 4.853519e-02
APOPTOSIS rest 2.181628 0.259184 3.005681e-02 1.001894e-01
COMPLEMENT rest 2.124511 0.270481 3.460229e-02 1.081322e-01
KRAS_SIGNALING_DN rest 1.902713 0.237761 5.823757e-02 1.712870e-01
INFLAMMATORY_RESPONSE rest 1.824169 0.212521 6.930214e-02 1.925059e-01
PI3K_AKT_MTOR_SIGNALING rest 1.793655 0.204911 7.409651e-02 1.929206e-01
DNA_REPAIR rest 1.742478 0.160966 8.263904e-02 1.929206e-01
GLYCOLYSIS rest 1.740437 0.196336 8.299339e-02 1.929206e-01
EPITHELIAL_MESENCHYMAL_TRANSITION rest 1.729782 0.212366 8.488509e-02 1.929206e-01
UNFOLDED_PROTEIN_RESPONSE rest 1.704517 0.170177 8.954355e-02 1.946599e-01
PANCREAS_BETA_CELLS rest 1.512385 0.159588 1.317006e-01 2.532705e-01
P53_PATHWAY rest 1.422636 0.150105 1.560845e-01 2.743878e-01
INTERFERON_ALPHA_RESPONSE rest 1.291190 0.139284 1.978169e-01 3.190595e-01
PROTEIN_SECRETION rest 1.230285 0.166442 2.197292e-01 3.433269e-01
E2F_TARGETS rest 1.192953 0.111780 2.340015e-01 3.545477e-01
IL2_STAT5_SIGNALING rest 1.071580 0.139397 2.849653e-01 4.190667e-01
ANDROGEN_RESPONSE rest 1.029095 0.143171 3.044195e-01 4.348851e-01
HYPOXIA rest 0.947164 0.104918 3.444606e-01 4.725928e-01
G2M_CHECKPOINT rest 0.936873 0.117459 3.497187e-01 4.725928e-01
APICAL_JUNCTION rest 0.882673 0.116597 3.782491e-01 4.976962e-01
HEME_METABOLISM rest 0.779315 0.104651 4.365207e-01 5.456509e-01
MYC_TARGETS_V2 rest 0.600183 0.044014 5.489215e-01 6.534780e-01
ANGIOGENESIS rest 0.489974 0.062189 6.245766e-01 7.232267e-01
WNT_BETA_CATENIN_SIGNALING rest 0.473253 0.053997 6.364395e-01 7.232267e-01
APICAL_SURFACE rest 0.392503 0.056158 6.950197e-01 7.554562e-01
SPERMATOGENESIS rest 0.232778 0.030223 8.161211e-01 8.161211e-01
SnC Endothelial Ground Control MITOTIC_SPINDLE rest 3.258011 1.478947 3.805116e-03 8.083137e-02
TGF_BETA_SIGNALING rest 2.941355 1.384740 7.676547e-03 8.083137e-02
APOPTOSIS rest 2.975580 1.335171 8.857444e-03 8.083137e-02
IL6_JAK_STAT3_SIGNALING rest 2.816275 0.752832 1.072240e-02 8.083137e-02
PROTEIN_SECRETION rest 2.564215 1.007616 1.887272e-02 1.048484e-01
NOTCH_SIGNALING rest 2.488042 0.896804 2.216619e-02 1.108309e-01
APICAL_JUNCTION rest 2.093046 1.157169 5.073864e-02 1.951486e-01
REACTIVE_OXYGEN_SPECIES_PATHWAY rest 1.935321 0.634651 6.683747e-02 2.387053e-01
ANDROGEN_RESPONSE rest 1.807020 0.714925 8.514720e-02 2.838240e-01
HEDGEHOG_SIGNALING rest 1.613041 0.647814 1.210153e-01 3.559274e-01
E2F_TARGETS rest 1.575661 0.524390 1.342795e-01 3.729987e-01
MTORC1_SIGNALING rest 1.402324 0.762088 1.751138e-01 4.608259e-01
IL2_STAT5_SIGNALING rest 1.080739 0.400099 2.956850e-01 6.720114e-01
G2M_CHECKPOINT rest 1.039856 0.522363 3.107505e-01 6.755446e-01
MYC_TARGETS_V1 rest 0.824629 0.596456 4.185894e-01 7.474810e-01
MYOGENESIS rest 0.726675 0.557906 4.755678e-01 7.809173e-01
UV_RESPONSE_DN rest 0.680010 0.291038 5.080616e-01 7.809173e-01
EPITHELIAL_MESENCHYMAL_TRANSITION rest 0.675980 0.277083 5.113815e-01 7.809173e-01
TNFA_SIGNALING_VIA_NFKB rest 0.480988 0.249353 6.353168e-01 8.585362e-01
UNFOLDED_PROTEIN_RESPONSE rest 0.397496 0.188742 6.948673e-01 8.890824e-01
BILE_ACID_METABOLISM rest 0.328097 0.152519 7.461721e-01 8.899172e-01
PEROXISOME rest 0.325984 0.159601 7.475304e-01 8.899172e-01
APICAL_SURFACE rest 0.224855 0.087958 8.248180e-01 9.590907e-01
CHOLESTEROL_HOMEOSTASIS rest 0.091858 0.063601 9.277623e-01 9.667337e-01
ESTROGEN_RESPONSE_LATE rest 0.088513 0.054675 9.303993e-01 9.667337e-01
MYC_TARGETS_V2 rest 0.055319 0.013706 9.567997e-01 9.667337e-01
Space Flight P53_PATHWAY rest 1.656970 1.154408 2.227517e-01 9.843963e-01
FATTY_ACID_METABOLISM rest 1.440087 1.248901 2.285704e-01 9.843963e-01
KRAS_SIGNALING_DN rest 1.382228 1.793627 2.391280e-01 9.843963e-01
UV_RESPONSE_UP rest 1.349375 1.457897 2.501123e-01 9.843963e-01
KRAS_SIGNALING_UP rest 1.210298 0.858342 3.084082e-01 9.843963e-01
ADIPOGENESIS rest 1.143115 1.153930 3.382869e-01 9.843963e-01
PANCREAS_BETA_CELLS rest 0.874927 0.755823 4.444977e-01 9.843963e-01
INFLAMMATORY_RESPONSE rest 0.686299 0.402708 5.578380e-01 9.843963e-01
WNT_BETA_CATENIN_SIGNALING rest 0.542168 0.416588 6.185467e-01 9.843963e-01
GLYCOLYSIS rest 0.504993 0.361742 6.537687e-01 9.843963e-01
INTERFERON_GAMMA_RESPONSE rest 0.473884 0.620932 6.603920e-01 9.843963e-01
HEME_METABOLISM rest 0.475097 0.373352 6.753055e-01 9.843963e-01
ESTROGEN_RESPONSE_EARLY rest 0.463498 0.289785 6.786472e-01 9.843963e-01
COMPLEMENT rest 0.337482 0.354969 7.595126e-01 9.843963e-01
ANGIOGENESIS rest 0.321828 0.330454 7.739396e-01 9.843963e-01
OXIDATIVE_PHOSPHORYLATION rest 0.323035 0.355209 7.746842e-01 9.843963e-01
XENOBIOTIC_METABOLISM rest 0.268079 0.188343 8.110869e-01 9.843963e-01
DNA_REPAIR rest 0.260233 0.177456 8.111853e-01 9.843963e-01
SPERMATOGENESIS rest 0.204693 0.210566 8.550464e-01 9.843963e-01
HYPOXIA rest 0.188765 0.199785 8.638931e-01 9.843963e-01
COAGULATION rest 0.075431 0.061910 9.446363e-01 9.843963e-01
INTERFERON_ALPHA_RESPONSE rest 0.074280 0.080148 9.462098e-01 9.843963e-01
PI3K_AKT_MTOR_SIGNALING rest 0.068150 0.048184 9.515520e-01 9.843963e-01
ALLOGRAFT_REJECTION rest 0.021158 0.026526 9.843963e-01 9.843963e-01
SnC Microglial Ground Control EPITHELIAL_MESENCHYMAL_TRANSITION rest 1.440658 0.404078 1.553477e-01 5.591584e-01
PEROXISOME rest 1.373162 0.358059 1.752125e-01 5.591584e-01
IL6_JAK_STAT3_SIGNALING rest 1.372558 0.350405 1.757632e-01 5.591584e-01
BILE_ACID_METABOLISM rest 1.260926 0.299801 2.126703e-01 5.907507e-01
MYOGENESIS rest 0.771268 0.194101 4.437985e-01 7.651699e-01
UV_RESPONSE_UP rest 0.673652 0.165443 5.034820e-01 8.120677e-01
G2M_CHECKPOINT rest 0.517848 0.139623 6.066064e-01 8.398744e-01
NOTCH_SIGNALING rest 0.348341 0.115534 7.290534e-01 8.413074e-01
PANCREAS_BETA_CELLS rest 0.336158 0.085310 7.380893e-01 8.413074e-01
ESTROGEN_RESPONSE_LATE rest 0.230938 0.051052 8.183012e-01 9.075081e-01
INFLAMMATORY_RESPONSE rest 0.204267 0.051541 8.389214e-01 9.075081e-01
IL2_STAT5_SIGNALING rest 0.141234 0.033671 8.881926e-01 9.075081e-01
ESTROGEN_RESPONSE_EARLY rest 0.123668 0.033802 9.020303e-01 9.075081e-01
Space Flight OXIDATIVE_PHOSPHORYLATION rest 3.811117 0.848163 3.066829e-04 1.533415e-02
SPERMATOGENESIS rest 2.718507 0.431131 8.465016e-03 1.726303e-01
ALLOGRAFT_REJECTION rest 2.449465 0.711605 1.699491e-02 1.726303e-01
ADIPOGENESIS rest 2.434296 0.504914 1.764277e-02 1.726303e-01
FATTY_ACID_METABOLISM rest 2.384960 0.439813 1.997116e-02 1.726303e-01
REACTIVE_OXYGEN_SPECIES_PATHWAY rest 2.374217 0.515640 2.071563e-02 1.726303e-01
MYC_TARGETS_V1 rest 2.253054 0.510957 2.768355e-02 1.751217e-01
APOPTOSIS rest 2.230415 0.529620 2.917642e-02 1.751217e-01
HEME_METABOLISM rest 2.174849 0.515986 3.341929e-02 1.751217e-01
KRAS_SIGNALING_UP rest 2.152448 0.506274 3.502433e-02 1.751217e-01
GLYCOLYSIS rest 1.819892 0.377820 7.332269e-02 3.332849e-01
COMPLEMENT rest 1.644387 0.436168 1.048592e-01 4.369132e-01
INTERFERON_GAMMA_RESPONSE rest 1.474014 0.424819 1.452898e-01 4.540305e-01
WNT_BETA_CATENIN_SIGNALING rest 1.376790 0.311849 1.734985e-01 4.913533e-01
MYC_TARGETS_V2 rest 1.231202 0.196730 2.226711e-01 5.859765e-01
MTORC1_SIGNALING rest 1.183149 0.238531 2.410463e-01 6.026158e-01
APICAL_SURFACE rest 1.125263 0.263601 2.645534e-01 6.129812e-01
APICAL_JUNCTION rest 1.037779 0.245304 3.032191e-01 6.129812e-01
TNFA_SIGNALING_VIA_NFKB rest 1.034940 0.257406 3.045002e-01 6.129812e-01
TGF_BETA_SIGNALING rest 1.023306 0.328814 3.099090e-01 6.129812e-01
ANDROGEN_RESPONSE rest 1.010718 0.243995 3.158426e-01 6.129812e-01
PI3K_AKT_MTOR_SIGNALING rest 1.004683 0.254420 3.187502e-01 6.129812e-01
P53_PATHWAY rest 0.933371 0.203040 3.540307e-01 6.556124e-01
HYPOXIA rest 0.841298 0.201779 4.032467e-01 7.011621e-01
CHOLESTEROL_HOMEOSTASIS rest 0.778259 0.181943 4.392603e-01 7.321005e-01
ANGIOGENESIS rest 0.596020 0.133813 5.532715e-01 8.033104e-01
KRAS_SIGNALING_DN rest 0.582424 0.134041 5.624000e-01 8.033104e-01
COAGULATION rest 0.566692 0.197444 5.729323e-01 8.033104e-01
INTERFERON_ALPHA_RESPONSE rest 0.538127 0.138115 5.923003e-01 8.033104e-01
XENOBIOTIC_METABOLISM rest 0.532792 0.117440 5.959806e-01 8.033104e-01
UV_RESPONSE_DN rest 0.511825 0.162355 6.105159e-01 8.033104e-01
PROTEIN_SECRETION rest 0.416829 0.104737 6.781942e-01 8.176644e-01
HEDGEHOG_SIGNALING rest 0.381716 0.091101 7.038987e-01 8.176644e-01
E2F_TARGETS rest 0.378163 0.077710 7.065556e-01 8.176644e-01
UNFOLDED_PROTEIN_RESPONSE rest 0.360619 0.069374 7.195447e-01 8.176644e-01
MITOTIC_SPINDLE rest 0.192950 0.048890 8.476142e-01 8.998196e-01
DNA_REPAIR rest 0.126399 0.026469 8.998196e-01 8.998196e-01
SnC Astrocyte Ground Control INTERFERON_ALPHA_RESPONSE rest 1.456071 0.189438 1.480762e-01 3.219047e-01
APICAL_JUNCTION rest 1.145709 0.197663 2.542790e-01 4.101274e-01
ALLOGRAFT_REJECTION rest 0.901015 0.167060 3.694925e-01 5.598371e-01
UV_RESPONSE_DN rest 0.781900 0.165101 4.358761e-01 6.226802e-01
ANGIOGENESIS rest 0.743924 0.161066 4.585001e-01 6.368057e-01
HEME_METABOLISM rest 0.664483 0.129212 5.077334e-01 6.488810e-01
INTERFERON_GAMMA_RESPONSE rest 0.642541 0.097926 5.217902e-01 6.488810e-01
APICAL_SURFACE rest 0.530951 0.084415 5.964695e-01 7.100827e-01
IL2_STAT5_SIGNALING rest 0.448764 0.086566 6.544502e-01 7.609886e-01
WNT_BETA_CATENIN_SIGNALING rest 0.293189 0.039791 7.699485e-01 8.384899e-01
PANCREAS_BETA_CELLS rest 0.291212 0.051798 7.714107e-01 8.384899e-01
TGF_BETA_SIGNALING rest 0.227882 0.049780 8.201393e-01 8.543118e-01
IL6_JAK_STAT3_SIGNALING rest 0.092210 0.013979 9.266954e-01 9.456076e-01
Space Flight OXIDATIVE_PHOSPHORYLATION rest 4.135787 1.269167 6.578064e-05 3.289032e-03
COAGULATION rest 3.827156 0.841291 2.084334e-04 5.210834e-03
ADIPOGENESIS rest 3.295846 0.813558 1.305001e-03 2.175002e-02
CHOLESTEROL_HOMEOSTASIS rest 3.073215 0.743432 2.627684e-03 2.972019e-02
REACTIVE_OXYGEN_SPECIES_PATHWAY rest 3.031995 0.521165 2.972019e-03 2.972019e-02
G2M_CHECKPOINT rest 2.845482 0.507279 5.204833e-03 4.317580e-02
MYC_TARGETS_V1 rest 2.797510 0.528136 6.044612e-03 4.317580e-02
HYPOXIA rest 2.681428 0.606257 8.418665e-03 4.933496e-02
NOTCH_SIGNALING rest 2.659382 0.486780 8.880294e-03 4.933496e-02
MTORC1_SIGNALING rest 2.569426 0.675254 1.141048e-02 5.224883e-02
GLYCOLYSIS rest 2.568020 0.495314 1.149474e-02 5.224883e-02
SPERMATOGENESIS rest 2.328058 0.386120 2.162334e-02 9.009725e-02
XENOBIOTIC_METABOLISM rest 2.187923 0.464307 3.060893e-02 1.177267e-01
FATTY_ACID_METABOLISM rest 1.927243 0.408874 5.629439e-02 2.010514e-01
PROTEIN_SECRETION rest 1.891015 0.356060 6.102348e-02 2.034116e-01
KRAS_SIGNALING_UP rest 1.680811 0.321696 9.538339e-02 2.980731e-01
P53_PATHWAY rest 1.622111 0.276149 1.073792e-01 3.002548e-01
COMPLEMENT rest 1.590685 0.356450 1.142690e-01 3.002548e-01
INFLAMMATORY_RESPONSE rest 1.581224 0.352387 1.164165e-01 3.002548e-01
ANDROGEN_RESPONSE rest 1.563807 0.270782 1.205143e-01 3.002548e-01
EPITHELIAL_MESENCHYMAL_TRANSITION rest 1.537647 0.299789 1.268488e-01 3.002548e-01
PEROXISOME rest 1.498559 0.274023 1.366439e-01 3.002548e-01
E2F_TARGETS rest 1.434435 0.170458 1.540362e-01 3.209088e-01
DNA_REPAIR rest 1.357480 0.181921 1.771480e-01 3.464186e-01
TNFA_SIGNALING_VIA_NFKB rest 1.328115 0.259823 1.866453e-01 3.464186e-01
ESTROGEN_RESPONSE_LATE rest 1.322312 0.275938 1.885408e-01 3.464186e-01
APOPTOSIS rest 1.306045 0.231854 1.939944e-01 3.464186e-01
MYOGENESIS rest 1.279678 0.255203 2.031209e-01 3.502085e-01
UV_RESPONSE_UP rest 1.204659 0.239568 2.306683e-01 3.844471e-01
KRAS_SIGNALING_DN rest 1.042138 0.198434 2.994240e-01 4.678500e-01
MYC_TARGETS_V2 rest 0.881438 0.100794 3.798556e-01 5.586112e-01
PI3K_AKT_MTOR_SIGNALING rest 0.730555 0.134849 4.664547e-01 6.303442e-01
ESTROGEN_RESPONSE_EARLY rest 0.657379 0.146514 5.121758e-01 6.363304e-01
HEDGEHOG_SIGNALING rest 0.642444 0.137294 5.217909e-01 6.363304e-01
BILE_ACID_METABOLISM rest 0.376496 0.069578 7.072089e-01 8.036465e-01
UNFOLDED_PROTEIN_RESPONSE rest 0.234439 0.037217 8.150927e-01 8.496711e-01
MITOTIC_SPINDLE rest 0.003854 0.000840 9.969314e-01 9.969314e-01

Individual Cell Scores¶

In [ ]:
res_aucell = scflow.ax.run_decoupler_aucell(
    self.rna, col_covariates=["Senescent_Cell_Label_by_Type", col_condition],
    resource="progeny", species=species, inplace=True)
_ = self.plot(genes=list(self.rna.obsm["score_aucell"].columns),
              subset=self.rna.obs["Senescent_Cell"],
              col_celltype=col_condition, kind="violin",
              by_group="Senescent_Cell_Label_by_Type", figsize=(15, 15))

DEGs (find_markers) by Group¶

In [ ]:
out_pathway_snc_degs = scflow.ax.run_enrichr(
    df_snc_markers_top, col_grouping=["Comparison", col_celltype],
    gene_sets=gene_sets, fx_replace_string=fx_replace_string, title="Overall")
out_pathway_snc_degs_gc = scflow.ax.run_enrichr(
    df_snc_markers_top_gc, col_grouping=["Comparison", col_celltype],
    gene_sets=gene_sets, fx_replace_string=fx_replace_string,
    title=keys[col_condition]["key_control"])
out_pathway_snc_degs_sf = scflow.ax.run_enrichr(
    df_snc_markers_top_sf, col_grouping=["Comparison", col_celltype],
    gene_sets=gene_sets, fx_replace_string=fx_replace_string,
    title=keys[col_condition]["key_treatment"])
# out_pathway_snc_degs[1].drop("All", level=0)

Edger Contrasts (Pseudo-Bulk)¶

In [ ]:
# GSEA
print("\n\nGSEA Enrichment Analysis\n\n")
out_pathway_snc_degs = scflow.ax.run_enrichr(
    out_edgr_contrasts_snc_all_top, col_grouping=col_celltype,
    gene_sets=gene_sets, fx_replace_string=fx_replace_string)

# ToppGene
print("\n\nToppGene Enrichment Analysis\n\n")
mks_ctrsts_snc = dict(out_edgr_contrasts_snc_all_top.reset_index(
    1).variable.groupby(col_celltype).apply(lambda x: list(x)))  # SnC DEGs
results_toppgene_degs = scflow.pp.annotate_by_toppgene(
    mks_ctrsts_snc, species=species, min_genes=1,
    categories=["Pathway", "PubMed"])
results_toppgene_degs = results_toppgene_degs.join(pd.Series(
    mks_ctrsts_snc).to_frame("DEGs").rename_axis("Gene Set"))
results_toppgene_degs = results_toppgene_degs.groupby("Gene Set").apply(
    lambda x: x.sort_values("PValue", ascending=True), include_groups=False)
pthwys = dict(results_toppgene_degs.groupby("Gene Set").apply(
    lambda x: [i.capitalize() for i in x.Name.unique()]))
print("\n\n".join([f"{k}: {pthwys[k]}" for k in pthwys]))
results_toppgene_degs[["Name", "Symbols", "GenesInTerm", "GenesInQuery",
                       "GenesInTermInQuery", "PValue"]].reset_index(
                           2, drop=True)

Plot¶

In [ ]:
# Top 10 Senescence Genes or All?
ggg = top_genes
# ggg = genes

# Mask for High Senescence Subset & Helper Variable for Figure Dimensions
subset = self.rna.obs["Senescent_Cell"].isin([1, True])
num_cts = len(self.rna[subset].obs[col_celltype].unique())

# Plot SnC Markers Overlap with Marker Sets
sc.pl.violin(self.rna[subset], set(genes).intersection(
    marker_gene_sets.explode().unique()),
             groupby=col_batch, rotation=90)  # plot overlap w/ SnC markers

# Plot Most Highly-Expressed Genes in Each Senescent Cell Type
_ = self.plot(kind=["matrix", "heat"], genes=top_genes,
              col_celltype=col_celltype, layer="log1p",
              subset=subset, dendrogram=True, swap_axes=False, heat=dict(
                  dendrogram=False), standard_scale="var",
              figsize=(len(top_genes) / 1.5, num_cts * 1.5))

# Grouped by Top Cell Types
_ = self.plot(kind=["matrix", "heat"], genes=top_genes_dict,
              standard_scale="obs", col_celltype=col_celltype,
              layer="log1p", swap_axes=False, figsize=(len(ggg), num_cts),
              subset=subset, dendrogram=True)

Write Object¶

In [ ]:
# Send Email with Output When Done
if email is not None and html_out is not None:
    os.system(f"jupyter nbconvert --to html {cur_file}")
    os.system(f"echo 'yay' | mutt -s 'JOB DONE' -a {html_out} -- {email}")

if overwrite is True or os.path.exists() is False:
    self.rna.write_h5ad(file_path_new)
else:
    print(f"\n\n\n{'=' * 120}\nOVERWRITE IS FALSE..."
          f"NOT WRITING OBJECT!!!\n{'=' * 120}\n\n\n")

SCRATCH¶

In [ ]:
# df_degs = out_edgr_old_sf_v_gc.copy()
# df_degs = out_edgr_batches_snc_top.copy()
# df_degs = res_snc_grps.copy()
df_degs = df_snc_markers.drop("All").reset_index(0, drop=True)

factor_name = col_celltype
# factor_name = col_condition

names = gp.get_library_name()
# [i for i in names if "brain" in i.lower() or "mouse" in i.lower()]
pathways_snc_vs_no, res_pathways_snc_vs_no = {}, {}
thresh_p_path = 0.05
# perts_geo = ["Aging", "Drug", "Disease"]
perts_geo = ["Aging", "Disease"]
other_sets = ["GTEx_Aging_Signatures_2021", f"HDSigDB_{species}_2021",
              # "DGIdb_Drug_Targets_2024",
              "MSigDB_Hallmark_2020",
              "MSigDB_Oncogenic_Signatures", "OMIM_Disease",
              # "Reactome_Pathways_2024", "Reactome_2022",
              f"WikiPathways_2024_{species}", f"WikiPathways_2019_{species}"]
other_sets += [i for i in names if "GO_Biological_Process" in i]
gene_sets = dict(zip(["up", "down"], [[
    f"{u}_Perturbations_from_GEO_{i}" for u in perts_geo] + [
        f"Disease_Signatures_from_GEO_{i}_2014"] + other_sets
    for i in ["up", "down"]]))
# if species.lower() == "mouse":
#     other_sets += ["PerturbAtlas_MouseGenePerturbationSigs"]
for x in df_degs.reset_index()[factor_name].unique():
    pathways_snc_vs_no[x], res_pathways_snc_vs_no[x] = {}, {}
    for i in ["up", "down"]:
        degs_tmp = df_degs.loc[x]
        if i == "up":
            degs_tmp = list(degs_tmp[degs_tmp.log_fc > 0].index.values)
        else:
            degs_tmp = list(degs_tmp[degs_tmp.log_fc < 0].index.values)
        if len(degs_tmp) > 0:
            g_s = [f"{u}_Perturbations_from_GEO_{i}" for u in perts_geo] + [
                f"Disease_Signatures_from_GEO_{i}_2014"] + other_sets
            g_s = [g for g in g_s if g in names]
            pathways_snc_vs_no[x][i] = gp.enrichr(
                gene_list=degs_tmp, gene_sets=g_s,
                organism=species, cutoff=0.5)
            res_pathways_snc_vs_no[x][i] = pathways_snc_vs_no[x][i].results[
                pathways_snc_vs_no[x][i].results[
                    "Adjusted P-value"] < thresh_p_path]
    res_pathways_snc_vs_no[x] = pd.concat(res_pathways_snc_vs_no[x],
                                          names=["Direction"])
res_pathways_snc_vs_no = pd.concat(res_pathways_snc_vs_no,
                                   names=[col_celltype])
res_pathways_snc_vs_no.loc[
    :, "Term Short"] = res_pathways_snc_vs_no.Term.apply(
        lambda x: re.sub("Expression Of ", "", re.sub(".*.xls", "", re.sub(
            ".*.XLSX", "",
            re.sub(".*Supplementary Table [0-9]+[-]?", "", re.sub(
                ".*.xlsx.", "", re.sub(".*Supplementary Data ..", "", re.sub(
                    "PMID([0-9])+", "", re.sub(
                        "([0-9]+) years v ([0-9]+) years", "\\1 v \\2 yrs.",
                        re.sub("aging:([0-9]+)", "aging", re.sub(
                            "([0-9]+) months v ([0-9]+) mo(nths)?",
                            "\\1 v \\2 mo.", re.sub("SRP[0-9]+ ", "", re.sub(
                                "GSE[0-9]+ ", "", x)))))))))))))
cts_i = res_pathways_snc_vs_no.reset_index()[col_celltype].unique()
res_pathways_snc_top_vs_no = res_pathways_snc_vs_no.reset_index().groupby([
    col_celltype, "Direction"]).apply(lambda x: x.sort_values(
        "Adjusted P-value", ascending=True).head(10), include_groups=False)
fig, axes = plt.subplots(*scflow.pl.square_grid(cts_i), figsize=(
    20, 25), gridspec_kw=dict(wspace=1.5, top=0.95), squeeze=False)
for i, x in enumerate(cts_i):
    gp.dotplot(
        res_pathways_snc_top_vs_no.loc[x].reset_index(),
        column="Adjusted P-value",
        # column="Overlap",
        x="Direction", y="Term Short",
        ax=axes.flatten()[i], size=20, top_term=100,
        title=x, xticklabels_rot=45, yticklabels_rot=45,
        show_ring=True, marker="o", cutoff=0.5)
    axes.flatten()[i].tick_params(axis="y", labelsize=8,
                                  labelfontfamily="serif")
    axes.flatten()[i].tick_params(axis="x", labelsize=10,
                                  labelfontfamily="serif")
    axes.flatten()[i].title.set_fontsize(10)
if len(axes.flatten()) > len(cts_i):
    for a in axes.flatten()[len(cts_i):]:
        a.set_visible(False)
fig.suptitle("Senescent Cell Spaceflight DEGs", fontsize="xx-large",
             fontproperties=dict(family="serif"))
res_pathways_snc_top_vs_no[["Term Short", "Genes"] + list(
    res_pathways_snc_top_vs_no.columns.difference([
        "Term", "Genes", "Term Short"]))]
In [ ]:
# df_degs = out_edgr_old_sf_v_gc.copy()
# df_degs = out_edgr_batches_snc_top.copy()
# df_degs = res_snc_grps.copy()

# factor_name = col_celltype
# factor_name = col_condition
factor_name = col_batch

df_degs = res_rank_genes_top.loc[:, "Overall", :]
df_degs = df_degs.assign(log_fc=df_degs.logfoldchanges.abs())
df_degs = df_degs.assign(abs_log_fc=df_degs.logfoldchanges_abs)

names = gp.get_library_name()
# [i for i in names if "brain" in i.lower() or "mouse" in i.lower()]
pathways_snc_vs_no, res_pathways_snc_vs_no = {}, {}
thresh_p_path = 0.05
# perts_geo = ["Aging", "Drug", "Disease"]
perts_geo = ["Aging", "Disease"]
other_sets = ["GTEx_Aging_Signatures_2021", f"HDSigDB_{species}_2021",
              # "DGIdb_Drug_Targets_2024",
              "MSigDB_Hallmark_2020",
              "MSigDB_Oncogenic_Signatures", "OMIM_Disease",
              # "Reactome_Pathways_2024", "Reactome_2022",
              f"WikiPathways_2024_{species}", f"WikiPathways_2019_{species}"]
other_sets += [i for i in names if "GO_Biological_Process" in i]
# if species.lower() == "mouse":
#     other_sets += ["PerturbAtlas_MouseGenePerturbationSigs"]
for x in df_degs.reset_index()[factor_name].unique():
    pathways_snc_vs_no[x], res_pathways_snc_vs_no[x] = {}, {}
    for i in ["up", "down"]:
        degs_tmp = df_degs.loc[x]
        if i == "up":
            degs_tmp = list(degs_tmp[degs_tmp.log_fc > 0].index.values)
        else:
            degs_tmp = list(degs_tmp[degs_tmp.log_fc < 0].index.values)
        if len(degs_tmp) > 0:
            g_s = [f"{u}_Perturbations_from_GEO_{i}" for u in perts_geo] + [
                f"Disease_Signatures_from_GEO_{i}_2014"] + other_sets
            g_s = [g for g in g_s if g in names]
            pathways_snc_vs_no[x][i] = gp.enrichr(
                gene_list=degs_tmp, gene_sets=g_s,
                organism=species, cutoff=0.5)
            res_pathways_snc_vs_no[x][i] = pathways_snc_vs_no[x][i].results[
                pathways_snc_vs_no[x][i].results[
                    "Adjusted P-value"] < thresh_p_path]
    res_pathways_snc_vs_no[x] = pd.concat(res_pathways_snc_vs_no[x],
                                          names=["Direction"])
res_pathways_snc_vs_no = pd.concat(res_pathways_snc_vs_no,
                                   names=[col_celltype])
res_pathways_snc_vs_no.loc[
    :, "Term Short"] = res_pathways_snc_vs_no.Term.apply(
        lambda x: re.sub("Expression Of ", "", re.sub(".*.xls", "", re.sub(
            ".*.XLSX", "",
            re.sub(".*Supplementary Table [0-9]+[-]?", "", re.sub(
                ".*.xlsx.", "", re.sub(".*Supplementary Data ..", "", re.sub(
                    "PMID([0-9])+", "", re.sub(
                        "([0-9]+) years v ([0-9]+) years", "\\1 v \\2 yrs.",
                        re.sub("aging:([0-9]+)", "aging", re.sub(
                            "([0-9]+) months v ([0-9]+) mo(nths)?",
                            "\\1 v \\2 mo.", re.sub("SRP[0-9]+ ", "", re.sub(
                                "GSE[0-9]+ ", "", x)))))))))))))
cts_i = res_pathways_snc_vs_no.reset_index()[col_celltype].unique()
res_pathways_snc_top_vs_no = res_pathways_snc_vs_no.reset_index().groupby([
    col_celltype, "Direction"]).apply(lambda x: x.sort_values(
        "Adjusted P-value", ascending=True).head(10), include_groups=False)
fig, axes = plt.subplots(*scflow.pl.square_grid(cts_i), figsize=(
    20, 25), gridspec_kw=dict(wspace=1.5, top=0.95), squeeze=False)
for i, x in enumerate(cts_i):
    gp.dotplot(
        res_pathways_snc_top_vs_no.loc[x].reset_index(),
        column="Adjusted P-value",
        # column="Overlap",
        x="Direction", y="Term Short",
        ax=axes.flatten()[i], size=20, top_term=100,
        title=x, xticklabels_rot=45, yticklabels_rot=45,
        show_ring=True, marker="o", cutoff=0.5)
    axes.flatten()[i].tick_params(axis="y", labelsize=8,
                                  labelfontfamily="serif")
    axes.flatten()[i].tick_params(axis="x", labelsize=10,
                                  labelfontfamily="serif")
    axes.flatten()[i].title.set_fontsize(10)
if len(axes.flatten()) > len(cts_i):
    for a in axes.flatten()[len(cts_i):]:
        a.set_visible(False)
fig.suptitle("Senescent Cell Spaceflight DEGs",
             fontsize="xx-large",
             fontproperties=dict(family="serif"))
res_pathways_snc_top_vs_no[["Term Short", "Genes"] + list(
    res_pathways_snc_top_vs_no.columns.difference([
        "Term", "Genes", "Term Short"]))]
In [ ]:
# df_degs = out_edgr_old_sf_v_gc.copy()
# df_degs = out_edgr_batches_snc_top.copy()
# df_degs = res_snc_grps.copy()

factor_name = col_celltype
# factor_name = col_condition

iii = 2
df_degs = res_rank_genes_top.loc[self.rna.obs[col_batch].unique()[iii]]
df_degs = df_degs.assign(log_fc=df_degs.logfoldchanges.abs())
df_degs = df_degs.assign(abs_log_fc=df_degs.logfoldchanges_abs)
print(self.rna.obs[col_batch].unique()[iii])

names = gp.get_library_name()
# [i for i in names if "brain" in i.lower() or "mouse" in i.lower()]
pathways_snc_vs_no, res_pathways_snc_vs_no = {}, {}
thresh_p_path = 0.05
# perts_geo = ["Aging", "Drug", "Disease"]
perts_geo = ["Aging", "Disease"]
other_sets = ["GTEx_Aging_Signatures_2021", f"HDSigDB_{species}_2021",
              # "DGIdb_Drug_Targets_2024",
              "MSigDB_Hallmark_2020",
              "MSigDB_Oncogenic_Signatures", "OMIM_Disease",
              # "Reactome_Pathways_2024", "Reactome_2022",
              f"WikiPathways_2024_{species}", f"WikiPathways_2019_{species}"]
other_sets += [i for i in names if "GO_Biological_Process" in i]
# if species.lower() == "mouse":
#     other_sets += ["PerturbAtlas_MouseGenePerturbationSigs"]
for x in df_degs.reset_index()[factor_name].unique():
    pathways_snc_vs_no[x], res_pathways_snc_vs_no[x] = {}, {}
    for i in ["up", "down"]:
        degs_tmp = df_degs.loc[x]
        if i == "up":
            degs_tmp = list(degs_tmp[degs_tmp.log_fc > 0].index.values)
        else:
            degs_tmp = list(degs_tmp[degs_tmp.log_fc < 0].index.values)
        if len(degs_tmp) > 0:
            g_s = [f"{u}_Perturbations_from_GEO_{i}" for u in perts_geo] + [
                f"Disease_Signatures_from_GEO_{i}_2014"] + other_sets
            g_s = [g for g in g_s if g in names]
            pathways_snc_vs_no[x][i] = gp.enrichr(
                gene_list=degs_tmp, gene_sets=g_s,
                organism=species, cutoff=0.5)
            res_pathways_snc_vs_no[x][i] = pathways_snc_vs_no[x][i].results[
                pathways_snc_vs_no[x][i].results[
                    "Adjusted P-value"] < thresh_p_path]
    res_pathways_snc_vs_no[x] = pd.concat(res_pathways_snc_vs_no[x],
                                          names=["Direction"])
res_pathways_snc_vs_no = pd.concat(res_pathways_snc_vs_no,
                                   names=[col_celltype])
res_pathways_snc_vs_no.loc[
    :, "Term Short"] = res_pathways_snc_vs_no.Term.apply(
        lambda x: re.sub("Expression Of ", "", re.sub(".*.xls", "", re.sub(
            ".*.XLSX", "",
            re.sub(".*Supplementary Table [0-9]+[-]?", "", re.sub(
                ".*.xlsx.", "", re.sub(".*Supplementary Data ..", "", re.sub(
                    "PMID([0-9])+", "", re.sub(
                        "([0-9]+) years v ([0-9]+) years", "\\1 v \\2 yrs.",
                        re.sub("aging:([0-9]+)", "aging", re.sub(
                            "([0-9]+) months v ([0-9]+) mo(nths)?",
                            "\\1 v \\2 mo.", re.sub("SRP[0-9]+ ", "", re.sub(
                                "GSE[0-9]+ ", "", x)))))))))))))
cts_i = res_pathways_snc_vs_no.reset_index()[col_celltype].unique()
res_pathways_snc_top_vs_no = res_pathways_snc_vs_no.reset_index().groupby([
    col_celltype, "Direction"]).apply(lambda x: x.sort_values(
        "Adjusted P-value", ascending=True).head(10), include_groups=False)
fig, axes = plt.subplots(*scflow.pl.square_grid(cts_i), figsize=(
    20, 25), gridspec_kw=dict(wspace=1.5, top=0.95), squeeze=False)
for i, x in enumerate(cts_i):
    gp.dotplot(
        res_pathways_snc_top_vs_no.loc[x].reset_index(),
        column="Adjusted P-value",
        # column="Overlap",
        x="Direction", y="Term Short",
        ax=axes.flatten()[i], size=20, top_term=100,
        title=x, xticklabels_rot=45, yticklabels_rot=45,
        show_ring=True, marker="o", cutoff=0.5)
    axes.flatten()[i].tick_params(axis="y", labelsize=8,
                                  labelfontfamily="serif")
    axes.flatten()[i].tick_params(axis="x", labelsize=10,
                                  labelfontfamily="serif")
    axes.flatten()[i].title.set_fontsize(10)
if len(axes.flatten()) > len(cts_i):
    for a in axes.flatten()[len(cts_i):]:
        a.set_visible(False)
fig.suptitle("Senescent Cell Spaceflight DEGs", fontsize="xx-large",
             fontproperties=dict(family="serif"))
res_pathways_snc_top_vs_no[["Term Short", "Genes"] + list(
    res_pathways_snc_top_vs_no.columns.difference([
        "Term", "Genes", "Term Short"]))]
In [ ]:
# df_degs = out_edgr_old_sf_v_gc.copy()
# df_degs = out_edgr_batches_snc_top.copy()
# df_degs = res_snc_grps.copy()

factor_name = col_celltype
# factor_name = col_condition

iii = 1
df_degs = res_rank_genes_top.loc[self.rna.obs[col_batch].unique()[iii]]
df_degs = df_degs.assign(log_fc=df_degs.logfoldchanges.abs())
df_degs = df_degs.assign(abs_log_fc=df_degs.logfoldchanges_abs)
print(self.rna.obs[col_batch].unique()[iii])

names = gp.get_library_name()
# [i for i in names if "brain" in i.lower() or "mouse" in i.lower()]
pathways_snc_vs_no, res_pathways_snc_vs_no = {}, {}
thresh_p_path = 0.05
# perts_geo = ["Aging", "Drug", "Disease"]
perts_geo = ["Aging", "Disease"]
other_sets = ["GTEx_Aging_Signatures_2021", f"HDSigDB_{species}_2021",
              # "DGIdb_Drug_Targets_2024",
              "MSigDB_Hallmark_2020",
              "MSigDB_Oncogenic_Signatures", "OMIM_Disease",
              # "Reactome_Pathways_2024", "Reactome_2022",
              f"WikiPathways_2024_{species}", f"WikiPathways_2019_{species}"]
other_sets += [i for i in names if "GO_Biological_Process" in i]
# if species.lower() == "mouse":
#     other_sets += ["PerturbAtlas_MouseGenePerturbationSigs"]
for x in df_degs.reset_index()[factor_name].unique():
    pathways_snc_vs_no[x], res_pathways_snc_vs_no[x] = {}, {}
    for i in ["up", "down"]:
        degs_tmp = df_degs.loc[x]
        if i == "up":
            degs_tmp = list(degs_tmp[degs_tmp.log_fc > 0].index.values)
        else:
            degs_tmp = list(degs_tmp[degs_tmp.log_fc < 0].index.values)
        if len(degs_tmp) > 0:
            g_s = [f"{u}_Perturbations_from_GEO_{i}" for u in perts_geo] + [
                f"Disease_Signatures_from_GEO_{i}_2014"] + other_sets
            g_s = [g for g in g_s if g in names]
            pathways_snc_vs_no[x][i] = gp.enrichr(
                gene_list=degs_tmp, gene_sets=g_s,
                organism=species, cutoff=0.5)
            res_pathways_snc_vs_no[x][i] = pathways_snc_vs_no[x][i].results[
                pathways_snc_vs_no[x][i].results[
                    "Adjusted P-value"] < thresh_p_path]
    res_pathways_snc_vs_no[x] = pd.concat(res_pathways_snc_vs_no[x],
                                          names=["Direction"])
res_pathways_snc_vs_no = pd.concat(res_pathways_snc_vs_no,
                                   names=[col_celltype])
res_pathways_snc_vs_no.loc[
    :, "Term Short"] = res_pathways_snc_vs_no.Term.apply(
        lambda x: re.sub("Expression Of ", "", re.sub(".*.xls", "", re.sub(
            ".*.XLSX", "",
            re.sub(".*Supplementary Table [0-9]+[-]?", "", re.sub(
                ".*.xlsx.", "", re.sub(".*Supplementary Data ..", "", re.sub(
                    "PMID([0-9])+", "", re.sub(
                        "([0-9]+) years v ([0-9]+) years", "\\1 v \\2 yrs.",
                        re.sub("aging:([0-9]+)", "aging", re.sub(
                            "([0-9]+) months v ([0-9]+) mo(nths)?",
                            "\\1 v \\2 mo.", re.sub("SRP[0-9]+ ", "", re.sub(
                                "GSE[0-9]+ ", "", x)))))))))))))
cts_i = res_pathways_snc_vs_no.reset_index()[col_celltype].unique()
res_pathways_snc_top_vs_no = res_pathways_snc_vs_no.reset_index().groupby([
    col_celltype, "Direction"]).apply(lambda x: x.sort_values(
        "Adjusted P-value", ascending=True).head(10), include_groups=False)
fig, axes = plt.subplots(*scflow.pl.square_grid(cts_i), figsize=(
    20, 25), gridspec_kw=dict(wspace=1.5, top=0.95), squeeze=False)
for i, x in enumerate(cts_i):
    gp.dotplot(
        res_pathways_snc_top_vs_no.loc[x].reset_index(),
        column="Adjusted P-value",
        # column="Overlap",
        x="Direction", y="Term Short",
        ax=axes.flatten()[i], size=20, top_term=100,
        title=x, xticklabels_rot=45, yticklabels_rot=45,
        show_ring=True, marker="o", cutoff=0.5)
    axes.flatten()[i].tick_params(axis="y", labelsize=8,
                                  labelfontfamily="serif")
    axes.flatten()[i].tick_params(axis="x", labelsize=10,
                                  labelfontfamily="serif")
    axes.flatten()[i].title.set_fontsize(10)
if len(axes.flatten()) > len(cts_i):
    for a in axes.flatten()[len(cts_i):]:
        a.set_visible(False)
fig.suptitle("Senescent Cell Spaceflight DEGs", fontsize="xx-large",
             fontproperties=dict(family="serif"))
res_pathways_snc_top_vs_no[["Term Short", "Genes"] + list(
    res_pathways_snc_top_vs_no.columns.difference([
        "Term", "Genes", "Term Short"]))]